Improve docker build
- add .dockerignore - add entrypoint.sh to ensure proper permissions in Docker volumes - add TZ variable for consistent Celery timestamps
This commit is contained in:
parent
38dae51a7a
commit
f89de16f6e
7 changed files with 43 additions and 18 deletions
18
.dockerignore
Normal file
18
.dockerignore
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
**/*.pyc
|
||||||
|
**/.*.swp
|
||||||
|
**/.coverage
|
||||||
|
**/__pycache__
|
||||||
|
.dockerignore
|
||||||
|
.env
|
||||||
|
.envrc
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.idea
|
||||||
|
.isort.cfg
|
||||||
|
.vagrant
|
||||||
|
Dockerfile
|
||||||
|
Vagrantfile
|
||||||
|
docker-compose.yml
|
||||||
|
docs
|
||||||
|
media
|
||||||
|
static
|
14
Dockerfile
14
Dockerfile
|
@ -51,22 +51,20 @@ ARG GVAAPP=gva
|
||||||
ARG GVAGID=2000
|
ARG GVAGID=2000
|
||||||
ARG GVAUID=2000
|
ARG GVAUID=2000
|
||||||
|
|
||||||
VOLUME /srv/$GVAAPP/media /srv/$GVAAPP/static
|
|
||||||
|
|
||||||
WORKDIR /srv/$GVAAPP
|
|
||||||
|
|
||||||
RUN addgroup --gid $GVAGID $GVAAPP ; \
|
RUN addgroup --gid $GVAGID $GVAAPP ; \
|
||||||
adduser --home /home/$GVAAPP --shell /bin/bash --uid $GVAUID --gid $GVAGID --disabled-password \
|
adduser --home /home/$GVAAPP --shell /bin/bash --uid $GVAUID --gid $GVAGID --disabled-password \
|
||||||
--gecos "User for gnuviechadmin component $GVAAPP" $GVAAPP
|
--gecos "User for gnuviechadmin component $GVAAPP" $GVAAPP
|
||||||
|
|
||||||
COPY --chown=$GVAAPP:$GVAAPP --from=builder /srv/$GVAAPP/.venv /srv/$GVAAPP/.venv
|
COPY --chown=$GVAAPP:$GVAAPP --from=builder /srv/$GVAAPP/.venv /srv/$GVAAPP/.venv
|
||||||
|
|
||||||
USER $GVAAPP
|
WORKDIR /srv/$GVAAPP
|
||||||
|
|
||||||
VOLUME /srv/$GVAAPP
|
VOLUME /srv/$GVAAPP/media /srv/$GVAAPP/static
|
||||||
|
|
||||||
|
VOLUME /srv/$GVAAPP/gnuviechadmin
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
COPY ${GVAAPP}.sh /srv/
|
COPY ${GVAAPP}.sh entrypoint.sh /srv/
|
||||||
|
|
||||||
ENTRYPOINT ["dumb-init", "/srv/${GVAAPP}.sh"]
|
ENTRYPOINT ["dumb-init", "/srv/entrypoint.sh"]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
|
@ -36,9 +37,9 @@ services:
|
||||||
GVA_DOMAIN_NAME: localhost
|
GVA_DOMAIN_NAME: localhost
|
||||||
GVA_SITE_NAME: localhost
|
GVA_SITE_NAME: localhost
|
||||||
volumes:
|
volumes:
|
||||||
- "./docker/django_media:/srv/gva/media"
|
- "django_media:/srv/gva/media"
|
||||||
- "./docker/django_static:/srv/gva/static"
|
- "django_static:/srv/gva/static"
|
||||||
- ".:/srv/gva"
|
- "./gnuviechadmin:/srv/gva/gnuviechadmin"
|
||||||
web:
|
web:
|
||||||
image: gnuviech/gvaweb:buster
|
image: gnuviech/gvaweb:buster
|
||||||
build:
|
build:
|
||||||
|
@ -51,7 +52,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
env_file: ../gvaweb/.env
|
env_file: ../gvaweb/.env
|
||||||
volumes:
|
volumes:
|
||||||
- "../gvaweb:/srv/gvaweb"
|
- "../gvaweb/gvaweb:/srv/gvaweb/gvaweb"
|
||||||
ldap:
|
ldap:
|
||||||
image: gnuviech/gvaldap:buster
|
image: gnuviech/gvaldap:buster
|
||||||
build:
|
build:
|
||||||
|
@ -64,7 +65,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
env_file: ../gvaldap/.env
|
env_file: ../gvaldap/.env
|
||||||
volumes:
|
volumes:
|
||||||
- "../gvaldap:/srv/gvaldap"
|
- "../gvaldap/gvaldap:/srv/gvaldap/gvaldap"
|
||||||
file:
|
file:
|
||||||
image: gnuviech/gvafile:buster
|
image: gnuviech/gvafile:buster
|
||||||
build:
|
build:
|
||||||
|
@ -77,7 +78,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
env_file: ../gvafile/.env
|
env_file: ../gvafile/.env
|
||||||
volumes:
|
volumes:
|
||||||
- "../gvafile:/srv/gvafile"
|
- "../gvafile/gvafile:/srv/gvafile/gvafile"
|
||||||
pgsql:
|
pgsql:
|
||||||
image: gnuviech/gvapgsql:buster
|
image: gnuviech/gvapgsql:buster
|
||||||
build:
|
build:
|
||||||
|
@ -90,7 +91,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
env_file: ../gvapgsql/.env
|
env_file: ../gvapgsql/.env
|
||||||
volumes:
|
volumes:
|
||||||
- "../gvapgsql:/srv/gvapgsql"
|
- "../gvapgsql/gvapgsql:/srv/gvapgsql/gvapgsql"
|
||||||
mysql:
|
mysql:
|
||||||
image: gnuviech/gvamysql:buster
|
image: gnuviech/gvamysql:buster
|
||||||
build:
|
build:
|
||||||
|
@ -103,7 +104,7 @@ services:
|
||||||
- redis
|
- redis
|
||||||
env_file: ../gvamysql/.env
|
env_file: ../gvamysql/.env
|
||||||
volumes:
|
volumes:
|
||||||
- "../gvamysql:/srv/gvamysql"
|
- "../gvamysql/gvamysql:/srv/gvamysql/gvamysql"
|
||||||
volumes:
|
volumes:
|
||||||
django_media:
|
django_media:
|
||||||
django_static:
|
django_static:
|
||||||
|
|
7
entrypoint.sh
Executable file
7
entrypoint.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
chown -Rc gva.gva /srv/gva/media /srv/gva/static
|
||||||
|
|
||||||
|
su -c /srv/gva.sh gva
|
5
gva.sh
5
gva.sh
|
@ -14,11 +14,12 @@ do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo " db is ready"
|
echo ". db is ready"
|
||||||
|
|
||||||
|
export TZ="Europe/Berlin"
|
||||||
|
|
||||||
. /srv/gva/.venv/bin/activate
|
. /srv/gva/.venv/bin/activate
|
||||||
cd /srv/gva/gnuviechadmin
|
cd /srv/gva/gnuviechadmin
|
||||||
python3 manage.py compilemessages
|
|
||||||
python3 manage.py collectstatic --noinput
|
python3 manage.py collectstatic --noinput
|
||||||
python3 manage.py migrate --noinput
|
python3 manage.py migrate --noinput
|
||||||
python3 manage.py runserver 0.0.0.0:8000
|
python3 manage.py runserver 0.0.0.0:8000
|
||||||
|
|
Loading…
Reference in a new issue