-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b92ed80
commit 39b6e70
Showing
5 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM continuumio/miniconda3:23.10.0-1 | ||
|
||
COPY environment.yml . | ||
RUN conda env create | ||
|
||
WORKDIR /var/www/livedata | ||
|
||
COPY docker-entrypoint-coverage.sh /usr/bin/docker-entrypoint.sh | ||
|
||
COPY src/live_data_server app | ||
RUN mkdir ./static | ||
|
||
WORKDIR /var/www/livedata/app | ||
|
||
RUN echo "[run]\nsource=live_data_server,plots\nparallel=True\nrelative_files=True" > /var/www/livedata/app/.coveragerc | ||
|
||
#ENV COVERAGE_PROCESS_START /var/www/livedata/app/.coveragerc | ||
|
||
RUN chmod +x /usr/bin/docker-entrypoint.sh | ||
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "livedata", "/usr/bin/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
services: | ||
|
||
nginx: | ||
image: nginx:1.21.1 | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- web-static:/var/www/livedata/static | ||
- ./config/nginx/envlocal.conf:/etc/nginx/conf.d/nginx.conf | ||
depends_on: | ||
livedata: | ||
condition: service_healthy | ||
|
||
livedata: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.coverage | ||
network: host | ||
environment: | ||
APP_DEBUG: 1 # 0 for False, otherwise will evaluate to True | ||
DJANGO_SUPERUSER_USERNAME: ${DATABASE_USER} | ||
DJANGO_SUPERUSER_PASSWORD: ${DATABASE_PASS} | ||
DATABASE_NAME: ${DATABASE_NAME} | ||
DATABASE_USER: ${DATABASE_USER} | ||
DATABASE_PASS: ${DATABASE_PASS} | ||
DATABASE_HOST: ${DATABASE_HOST} | ||
DATABASE_PORT: ${DATABASE_PORT} | ||
LIVE_PLOT_SECRET_KEY: ${LIVE_PLOT_SECRET_KEY} | ||
command: /usr/bin/docker-entrypoint.sh | ||
volumes: | ||
- web-static:/var/www/livedata/static | ||
healthcheck: | ||
test: wget --no-verbose --tries=1 --spider http://localhost:8000/admin || exit 1 | ||
interval: 60s | ||
retries: 5 | ||
start_period: 20s | ||
timeout: 10s | ||
ports: | ||
- "8000:8000" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
|
||
db: | ||
# do not upgrade to version > 9.6.23 unless you also upgrade livedata image | ||
image: postgres:9.6.23 | ||
environment: | ||
POSTGRES_DB: ${DATABASE_NAME} | ||
POSTGRES_USER: ${DATABASE_USER} | ||
POSTGRES_PASSWORD: ${DATABASE_PASS} | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 5 | ||
ports: | ||
- "${DATABASE_PORT}:${DATABASE_PORT}" | ||
volumes: | ||
- db-data:/var/lib/postgresql/data/ | ||
|
||
volumes: | ||
web-static: | ||
db-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# wait for database | ||
until PGPASSWORD=${DATABASE_PASS} psql -h "${DATABASE_HOST}" -U "${DATABASE_USER}" -d "${DATABASE_NAME}" -c '\q'; do | ||
>&2 echo "Postgres is unavailable - sleeping" | ||
sleep 1 | ||
done | ||
|
||
cd /var/www/livedata/app | ||
|
||
# collect static files | ||
python manage.py collectstatic --noinput | ||
|
||
# migrate django models | ||
python manage.py makemigrations --noinput | ||
python manage.py migrate --noinput | ||
|
||
# create superuser | ||
#echo "from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SUPERUSER_USERNAME}', '${DJANGO_SUPERUSER_USERNAME}@example.com', '${DJANGO_SUPERUSER_PASSWORD}')" | python manage.py shell | ||
|
||
# Create the webcache | ||
python manage.py createcachetable webcache | ||
python manage.py ensure_adminuser --username=${DJANGO_SUPERUSER_USERNAME} --email='workflow@example.com' --password=${DJANGO_SUPERUSER_PASSWORD} | ||
|
||
# run application with code coverage | ||
coverage run -m gunicorn live_data_server.wsgi:application -b :8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters