Browse Source
new: [gogocarto] new charm
new: [gogocarto] new charm
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>pull/6/head
Valentin Lab
4 years ago
7 changed files with 379 additions and 1 deletions
-
33apache/build/Dockerfile
-
101gogocarto/README.org
-
23gogocarto/hooks/init
-
43gogocarto/hooks/mongo_database-relation-joined
-
66gogocarto/hooks/publish_dir-relation-joined
-
86gogocarto/lib/common
-
28gogocarto/metadata.yml
@ -0,0 +1,101 @@ |
|||
|
|||
* Important notice |
|||
|
|||
As the current docker install of gogocarto as of <2020-10-20 Tue> is |
|||
far from being mature, we try here to get only the released part. |
|||
|
|||
We are talking of: |
|||
[[https://gitlab.adullact.net/pixelhumain/GoGoCarto/-/blob/f3c10f16fc08b533ef44f1325fdb50f87fa73224/docs/installation_docker.md][gogocarto docker install documentation]] |
|||
|
|||
** Intermediate docker image is cached on docker.0k.io if needed |
|||
|
|||
To rebuild a new version, I pushed the huge docker image of |
|||
=gogocarto= container that is required in the process (that contains |
|||
apache and all build/install tools). Note that this should not require |
|||
to be rebuild if anything important changes in the directory =docker/=. |
|||
|
|||
Using: |
|||
|
|||
#+begin_src sh |
|||
docker_tree_hash=$(git rev-parse HEAD:docker) |
|||
docker tag docker_gogocarto docker.0k.io/gogocarto-builder:${docker_tree_hash} |
|||
docker push docker.0k.io/gogocarto-builder:${docker_tree_hash} |
|||
#+end_src |
|||
|
|||
So, if needed, it can be pulled back to avoid the hassle of making it: |
|||
|
|||
#+begin_src sh |
|||
docker_tree_hash=$(git rev-parse HEAD:docker) |
|||
docker pull docker.0k.io/gogocarto-builder:${docker_tree_hash} && |
|||
docker tag docker.0k.io/gogocarto-builder:${docker_tree_hash} docker_gogocarto |
|||
#+end_src |
|||
|
|||
You still need to do (as of <2020-10-20 Tue>): |
|||
- get the latest source code |
|||
- =make up= to launch de containers with the images |
|||
- =make shell= from the latest git repos |
|||
- =make init= in the container |
|||
|
|||
** Full release is cached on =docker.0k.io/downloads= |
|||
|
|||
This is the content of the source tree, once populated by =make init=. |
|||
|
|||
*** mongodb is not included |
|||
|
|||
As of <2020-10-23 Fri>, the =Makefile='s =init= target is: |
|||
|
|||
#+begin_src sh |
|||
$ grep ^init Makefile -A1 |
|||
init: install assets load-fixtures fix-perms ## Initialize the project |
|||
|
|||
#+end_src |
|||
|
|||
Note that ``load-fixtures`` target is actually mongodb initialization: |
|||
|
|||
#+begin_src sh |
|||
load-fixtures: ## Create the DB schema, generate DB classes and load fixtures |
|||
$(SYMFONY) doctrine:mongodb:schema:create |
|||
$(SYMFONY) doctrine:mongodb:generate:hydrators |
|||
$(SYMFONY) doctrine:mongodb:generate:proxies |
|||
$(SYMFONY) doctrine:mongodb:fixtures:load -n |
|||
#+end_src |
|||
|
|||
This will be done in the =hooks/mongo_database-relation-joined= accordingly. |
|||
|
|||
|
|||
*** o create the full data release bundle this is what was made: |
|||
|
|||
#+begin_src sh |
|||
## correct bundles links (no idea if it is needed) |
|||
( |
|||
cd web/bundles |
|||
for i in *; do |
|||
link_target=$(readlink "$i") |
|||
ln -sf /opt/apps/gogocarto"${link_target#/var/www}" "$i" |
|||
done |
|||
) |
|||
## Force original versions |
|||
git co web/index.php config/packages/doctrine_mongodb.yaml bin/console |
|||
sed -ri "s/^(<\?php)/\1\n\ini_set('memory.limit', '1024M');/" \ |
|||
web/index.php bin/console |
|||
sed -ri "s%dirname\(__DIR__\)\.'%'/opt/apps/gogocarto%g" \ |
|||
web/index.php |
|||
commit_sha=$(git describe HEAD --tags) |
|||
tar cjv \ |
|||
bin web vendor config src templates translations \ |
|||
--exclude=.git --exclude=.gitignore \ |
|||
> gogocarto-${commit_sha}.tar.bz2 |
|||
#+end_src |
|||
|
|||
This is still far from being perfect, I wonder if we can just remove |
|||
all non '\*.{php,yml,js}' files. I noticed many many unrelated files in |
|||
=vendor/=. |
|||
|
|||
We need =bin= for symphony utilities that allows to setup things. |
|||
|
|||
* Roadmap |
|||
|
|||
** TODO mongo / the default database name is probably not correctly set. |
|||
|
|||
Indeed, it seems it is defaulted to =gogocarto_default= and I didn't find |
|||
yet how to set it. There's a connection with SAAS mode I think. |
@ -0,0 +1,23 @@ |
|||
#!/bin/bash |
|||
|
|||
## Init is run on host |
|||
## For now it is run every time the script is launched, but |
|||
## it should be launched only once after build. |
|||
|
|||
## Accessible variables are: |
|||
## - SERVICE_NAME Name of current service |
|||
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any |
|||
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service |
|||
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service |
|||
|
|||
|
|||
. lib/common |
|||
|
|||
set -e |
|||
|
|||
|
|||
if ! [ -e "$GOGOCARTO_CODE" ]; then |
|||
gogocarto:init || exit 1 |
|||
fi |
|||
|
|||
gogocarto:config || exit 1 |
@ -0,0 +1,43 @@ |
|||
#!/bin/bash |
|||
|
|||
. lib/common |
|||
|
|||
set -e |
|||
|
|||
DBNAME="$(relation-get dbname)" || exit 1 |
|||
|
|||
initing="${GOGOCARTO_CODE}"/.initing-${DBNAME} |
|||
if [ -e "$initing" ]; then |
|||
exit 0 |
|||
fi |
|||
|
|||
|
|||
inited="${GOGOCARTO_CODE}"/.inited-${DBNAME} |
|||
|
|||
MONGO_URL=mongodb://${TARGET_SERVICE_NAME}:27017/${DBNAME} |
|||
|
|||
|
|||
cat <<EOF >> ${GOGOCARTO_CODE}/.env |
|||
|
|||
###> doctrine/mongodb-odm-bundle ### |
|||
MONGODB_URL=$MONGO_URL |
|||
###< doctrine/mongodb-odm-bundle ### |
|||
|
|||
EOF |
|||
|
|||
if [ -e "$inited" ]; then |
|||
exit 0 |
|||
fi |
|||
|
|||
## came from ``Makefile`` in git's gogocarto source code. Target load-fixtures. |
|||
touch "$initing" |
|||
trap_add EXIT,ERR "rm -v \"$initing\"" |
|||
symphony doctrine:mongodb:schema:create && |
|||
symphony doctrine:mongodb:generate:hydrators && |
|||
symphony doctrine:mongodb:generate:proxies && |
|||
symphony doctrine:mongodb:fixtures:load -n || { |
|||
err "Mongo database initialization failed." |
|||
exit 1 |
|||
} |
|||
|
|||
touch "$inited" |
@ -0,0 +1,66 @@ |
|||
#!/bin/bash |
|||
|
|||
. lib/common |
|||
|
|||
set -e |
|||
|
|||
domain=$(relation-get domain) || exit 1 |
|||
url=$(relation-get url) || exit 1 |
|||
# location=$CONFIGSTORE/$BASE_SERVICE_NAME/var/www/$domain |
|||
|
|||
upload_dir="${SERVICE_DATASTORE}/var/www/$domain/uploads" |
|||
if [ -d "$upload_dir" ]; then |
|||
uid_gid=$(stat --format=%u:%g "$upload_dir") |
|||
else |
|||
err "Upload dir '${upload_dir}' was not created. Can't continue." |
|||
exit 1 |
|||
fi |
|||
|
|||
dirs=( |
|||
/var/cache/gogocarto |
|||
/var/lib/gogocarto/sessions |
|||
/var/log/gogocarto |
|||
) |
|||
|
|||
to_create=() |
|||
for dir in "${dirs[@]}"; do |
|||
fdir="${SERVICE_DATASTORE}${dir}" |
|||
if ! [ -d "$fdir" ]; then |
|||
to_create+=("$fdir") |
|||
fi |
|||
done |
|||
|
|||
if [ "${#to_create[@]}" -gt 0 ]; then |
|||
mkdir -p "${to_create[@]}" && |
|||
chown -v "$uid_gid" "${to_create[@]}" && |
|||
chmod -v g+rwx "${to_create[@]}" |
|||
fi |
|||
|
|||
cat <<EOF >> "${GOGOCARTO_CODE}"/.env |
|||
|
|||
BASE_PROTOCOL=${url%%://*} |
|||
BASE_URL=$domain |
|||
BASE_PATH=/index.php |
|||
|
|||
EOF |
|||
|
|||
|
|||
cat <<EOF > "${GOGOCARTO_CODE}"/web/.htaccess |
|||
|
|||
Options -MultiViews |
|||
RewriteEngine On |
|||
RewriteCond %{REQUEST_FILENAME} !-f |
|||
RewriteRule ^(.*)$ index.php/\$1 [QSA,L] |
|||
|
|||
EOF |
|||
|
|||
|
|||
config-add " |
|||
services: |
|||
$MASTER_TARGET_SERVICE_NAME: |
|||
volumes: |
|||
- $SERVICE_CONFIGSTORE/opt/apps/gogocarto:/opt/apps/gogocarto:rw |
|||
- $SERVICE_DATASTORE/var/cache/gogocarto:/opt/apps/gogocarto/var/cache:rw |
|||
- $SERVICE_DATASTORE/var/lib/gogocarto/sessions:/opt/apps/gogocarto/var/sessions:rw |
|||
- $SERVICE_DATASTORE/var/log/gogocarto:/opt/apps/gogocarto/var/log:rw |
|||
" |
@ -0,0 +1,86 @@ |
|||
# -*- mode: shell-script -*- |
|||
|
|||
|
|||
GOGOCARTO_CODE="$SERVICE_CONFIGSTORE/opt/apps/gogocarto" |
|||
GOGOCARTO_RELEASE=3.1.3-2-gf3c10f1 |
|||
GOGOCARTO_URL=https://docker.0k.io/downloads/gogocarto-"${GOGOCARTO_RELEASE}".tar.bz2 |
|||
|
|||
|
|||
gogocarto:init() { |
|||
mkdir -p "${GOGOCARTO_CODE}" && |
|||
cd "${GOGOCARTO_CODE}" && |
|||
curl "$GOGOCARTO_URL" | tar xjv |
|||
} |
|||
|
|||
|
|||
gogocarto:config() { |
|||
|
|||
APP_ENV=$(options-get app-env 2>/dev/null) || true |
|||
APP_ENV=${APP_ENV:-prod} |
|||
|
|||
cat <<EOF > "${GOGOCARTO_CODE}"/.env |
|||
|
|||
###> symfony/framework-bundle ### |
|||
APP_ENV=$APP_ENV |
|||
APP_SECRET=82ec369b81caab5446ddfc3b5edb4d00 |
|||
CSRF_PROTECTION=$( |
|||
[ "$APP_ENV" == "prod" ] && |
|||
echo "true" || |
|||
echo "false") ## active csrf protection on production servers |
|||
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 |
|||
#TRUSTED_HOSTS='^localhost|example\.com$' |
|||
###< symfony/framework-bundle ### |
|||
|
|||
|
|||
###> vich upload ### |
|||
IMAGES_MAX_FILESIZE=8M # for public images upload |
|||
IMAGE_RESIZE_WIDTH=1000 # in pixel |
|||
FILES_MAX_FILESIZE=1M # for other public file upload |
|||
###> vich upload ### |
|||
|
|||
USE_AS_SAAS=false |
|||
CONTACT_EMAIL=contact@localhost.fr |
|||
INSTANCE_NAME=GoGoCarto |
|||
|
|||
|
|||
###> symfony/swiftmailer-bundle ### |
|||
# For Gmail as a transport, use: "gmail://username:password@localhost" |
|||
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" |
|||
# Delivery is disabled by default via "null://localhost" |
|||
MAILER_URL=gmail://test.gogocarto:creerdescartesagogo@localhost |
|||
FROM_EMAIL=test.gogocarto@gmail.com |
|||
###< symfony/swiftmailer-bundle ### |
|||
|
|||
###> hwi/oauth-bundle ### |
|||
OAUTH_COMMUNS_ID=disabled |
|||
OAUTH_COMMUNS_SECRET=disabled |
|||
OAUTH_GOOGLE_ID=disabled |
|||
OAUTH_GOOGLE_SECRET=disabled |
|||
OAUTH_FACEBOOK_ID=disabled |
|||
OAUTH_FACEBOOK_SECRET=disabled |
|||
###< hwi/oauth-bundle ### |
|||
|
|||
###> sentry/sentry-symfony ### |
|||
# Log errors nicely with sentry. Create your account on sentry.io and provide the DSN here |
|||
# exple: SENTRY_DSN=https://6145d1aac36c429781fc1b0f79b0da48@sentry.io/1402018 |
|||
SENTRY_DSN= |
|||
###< sentry/sentry-symfony ### |
|||
EOF |
|||
|
|||
} |
|||
|
|||
|
|||
symphony() { |
|||
|
|||
export COMPOSE_IGNORE_ORPHANS=true |
|||
## We don't want post deploy that is doing the final http initialization. |
|||
compose --debug -q --no-init --no-post-deploy \ |
|||
--without-relation="$SERVICE_NAME":web-proxy \ |
|||
run \ |
|||
"${symphony_docker_run_opts[@]}" \ |
|||
-T --rm -w /opt/apps/gogocarto \ |
|||
--entrypoint php \ |
|||
-u www-data "$SERVICE_NAME" bin/console "$@" | cat |
|||
|
|||
return "${PIPESTATUS[0]}" |
|||
} |
@ -0,0 +1,28 @@ |
|||
description: Gogocarto server |
|||
subordinate: true |
|||
requires: |
|||
web-publishing-directory: |
|||
interface: publish-dir |
|||
scope: container |
|||
|
|||
|
|||
uses: |
|||
publish-dir: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
scope: container |
|||
constraint: required |
|||
auto: summon |
|||
solves: |
|||
container: "main running server" |
|||
default-options: |
|||
location: !var-expand "$CONFIGSTORE/$BASE_SERVICE_NAME/opt/apps/gogocarto/web" |
|||
data-dirs: ## write permission for web-app |
|||
- uploads |
|||
mongo-database: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
constraint: required |
|||
auto: summon |
|||
solves: |
|||
database: "main storage" |
Write
Preview
Loading…
Cancel
Save
Reference in new issue