Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117751119
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/docker/webapp/Dockerfile b/docker/webapp/Dockerfile
index cfbd755a..5daa33b7 100755
--- a/docker/webapp/Dockerfile
+++ b/docker/webapp/Dockerfile
@@ -1,17 +1,20 @@
FROM apheleia/swoole:latest
MAINTAINER Jeroen van Meeuwen <vanmeeuwen@apheleia-it.ch>
USER root
RUN dnf -y install findutils gnupg2 git rsync procps-ng php-sodium
EXPOSE 8000
ARG GIT_REF=master
+ARG CONFIG=config.prod
COPY build.sh /build.sh
RUN /build.sh
COPY init.sh /init.sh
COPY update.sh /update.sh
+ENV KOLAB_ROLE=combined
+
CMD [ "/init.sh" ]
diff --git a/docker/webapp/build.sh b/docker/webapp/build.sh
index 678149b8..b4880a2a 100755
--- a/docker/webapp/build.sh
+++ b/docker/webapp/build.sh
@@ -1,33 +1,35 @@
#!/bin/bash
set -e
set -x
echo -e "Building with the following ulimit: limit: $(ulimit -n)\n"
echo -e "If you run into EMFILE errors, this is the reason"
mkdir /src
cd /src
git clone --branch $GIT_REF https://git.kolab.org/source/kolab.git kolab
pushd kolab
git reset --hard $GIT_REF
+#TODO support injecting a custom overlay into the build process here
+bin/configure.sh $CONFIG
popd
rmdir /opt/app-root/src
cp -a kolab/src /opt/app-root/src
cd /opt/app-root/src/
mkdir -p storage/framework/{sessions,views,cache}
mkdir -p database/seeds
php -dmemory_limit=-1 $(command -v composer) install
npm -g install npm
/usr/local/bin/npm install
./artisan storage:link
./artisan clear-compiled
./artisan horizon:install
if [ ! -f 'resources/countries.php' ]; then
./artisan data:countries
fi
/usr/local/bin/npm run dev
diff --git a/docker/webapp/init.sh b/docker/webapp/init.sh
index 991e52cb..cf38ba95 100755
--- a/docker/webapp/init.sh
+++ b/docker/webapp/init.sh
@@ -1,39 +1,110 @@
#!/bin/bash
set -e
set -x
-rsync -av \
- --exclude=vendor \
- --exclude=composer.lock \
- --exclude=node_modules \
- --exclude=package-lock.json \
- --exclude=public \
- --exclude=storage \
- --exclude=resources/build \
- --exclude=bootstrap \
- --exclude=.gitignore \
- /src/kolabsrc.orig/ /opt/app-root/src/ | tee /tmp/rsync.output
-
cd /opt/app-root/src/
-rm -rf storage/framework
-mkdir -p storage/framework/{sessions,views,cache}
+# Update the sourcecode if available.
+# This also copies the .env files that is required if we don't provide
+# a configuration via the environment.
+# So we need this for the docker-compose setup
+if [ -d /src/kolabsrc.orig ]; then
+ echo "----> Updating source"
+ rsync -av \
+ --exclude=vendor \
+ --exclude=composer.lock \
+ --exclude=node_modules \
+ --exclude=package-lock.json \
+ --exclude=public \
+ --exclude=storage \
+ --exclude=resources/build \
+ --exclude=bootstrap \
+ --exclude=.gitignore \
+ /src/kolabsrc.orig/ /opt/app-root/src/ | tee /tmp/rsync.output
+
+ rm -rf storage/framework
+ mkdir -p storage/framework/{sessions,views,cache}
-find bootstrap/cache/ -type f ! -name ".gitignore" -delete
-./artisan clear-compiled
-./artisan cache:clear
+ find bootstrap/cache/ -type f ! -name ".gitignore" -delete
+ ./artisan clear-compiled
+ ./artisan cache:clear
-php -dmemory_limit=-1 $(command -v composer) install
+ php -dmemory_limit=-1 $(command -v composer) install
+fi
if [ ! -f 'resources/countries.php' ]; then
+ echo "----> Importing countries"
./artisan data:countries
fi
+echo "----> Waiting for db"
./artisan db:ping --wait
-php -dmemory_limit=512M ./artisan migrate --force
-if test "$( env APP_DEBUG=false ./artisan -n users | wc -l )" -lt "1"; then
- php -dmemory_limit=512M ./artisan db:seed
-fi
-./artisan data:import || :
-nohup ./artisan horizon 2>&1 &
-./artisan octane:start --host=$(grep OCTANE_HTTP_HOST .env | tail -n1 | sed "s/OCTANE_HTTP_HOST=//")
+
+case ${KOLAB_ROLE} in
+ seed|SEED)
+ # seed only if not seeded yet
+ if [[ ! $(./artisan migrate:status > /dev/null) ]]; then
+ echo "----> Seeding the database"
+ php -dmemory_limit=512M ./artisan migrate --seed || :
+ fi
+ ;;
+
+ horizon|HORIZON)
+
+ echo "----> Waiting for database to be seeded"
+ # migrate:status only fails if the migration table doesn't exist
+ while [[ ! $(./artisan migrate:status > /dev/null) ]]; do
+ sleep 1
+ echo "."
+ done
+
+ echo "----> Running migrations"
+ php -dmemory_limit=512M ./artisan migrate --force || :
+ echo "----> Starting horizon"
+ ./artisan horizon
+ ;;
+
+ octane|OCTANE)
+ echo "----> Running octane"
+
+ echo "----> Waiting for database to be seeded"
+ # migrate:status only fails if the migration table doesn't exist
+ while [[ ! $(./artisan migrate:status > /dev/null) ]]; do
+ sleep 1
+ echo "."
+ done
+
+ exec ./artisan octane:start --host=0.0.0.0
+ ;;
+
+ worker|WORKER )
+ ./artisan migrate --force || :
+ echo "----> Running worker"
+ exec ./artisan queue:work
+ ;;
+
+ combined|COMBINED )
+ # If there is no db at all then listing users will crash (resulting in us counting the lines of backtrace),
+ # but migrate:status will just fail.
+ if [[ ! $(./artisan migrate:status > /dev/null) ]]; then
+ echo "----> Seeding the database"
+ php -dmemory_limit=512M ./artisan migrate --seed || :
+ # If there is a db but no user we reseed
+ elif test "$( env APP_DEBUG=false ./artisan -n users | wc -l )" -lt "1"; then
+ echo "----> Initializing the database"
+ php -dmemory_limit=512M ./artisan migrate:refresh --seed
+ # Otherwise we just migrate
+ else
+ echo "----> Running migrations"
+ php -dmemory_limit=512M ./artisan migrate --force
+ fi
+ ./artisan data:import || :
+ nohup ./artisan horizon 2>&1 &
+ exec ./artisan octane:start --host=$(env | grep OCTANE_HTTP_HOST | tail -n1 | sed "s/OCTANE_HTTP_HOST=//")
+ ;;
+
+ * )
+ echo "----> Sleeping"
+ exec sleep 10000
+ ;;
+esac
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Apr 4, 2:51 AM (3 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822298
Default Alt Text
(6 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline