-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial docker experiment * This works - for me. * Fix env files We will default to 8001, since the default port for bornhack-website is 8000. The default db port is 5433. * Update Dockerfile to install dev,test dependencies Some dependencies from dev was not installed. * Move docker compose environment stuff into compose.yml and restore .env.dist. --------- Co-authored-by: Víðir Valberg Guðmundsson <valberg@orn.li>
- Loading branch information
1 parent
45ca8dc
commit 1950a62
Showing
4 changed files
with
110 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p bma -f docker/compose.yaml | ||
DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u` | ||
MANAGE_EXEC = ${DOCKER_COMPOSE} exec app python /app/src/manage.py | ||
MANAGE_RUN = ${DOCKER_RUN} app python /app/src/manage.py | ||
PARALLEL=4 | ||
TEST_OPTIONS = --failfast --keepdb --parallel ${PARALLEL} | ||
TEST_TO_RUN = . | ||
|
||
init: copy_env_file migrate | ||
|
||
run: | ||
${DOCKER_COMPOSE} up | ||
|
||
migrate: | ||
${MANAGE_RUN} $@ ${ARGS} | ||
|
||
makemigrations: | ||
${MANAGE_RUN} $@ ${ARGS} | ||
|
||
bootstrap_devsite: | ||
${MANAGE_RUN} $@ ${ARGS} | ||
|
||
shell: | ||
${MANAGE_RUN} $@ ${ARGS} | ||
|
||
manage: | ||
${MANAGE_RUN} ${COMMAND} | ||
|
||
test: | ||
${DOCKER_RUN} app \ | ||
bash -c "cd /app/src/; python manage.py test $(TEST_OPTIONS) ${TEST_TO_RUN}" | ||
|
||
build_docker_image: | ||
${DOCKER_COMPOSE} build app | ||
|
||
copy_env_file: | ||
test -f src/bma/environment_settings.py || cp src/bma/environment_settings.py.dist src/bma/environment_settings.py | ||
test -f docker/.env || cp docker/.env.dev docker/.env |
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,3 @@ | ||
# Ports are purposefully selected to not conflict with default ports for bornhack-website | ||
db_port=5433 | ||
web_port=8001 |
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,33 @@ | ||
FROM python:3.10-slim-bullseye | ||
|
||
ENV PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONHASHSEED=random \ | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
build-essential \ | ||
binutils \ | ||
python3-dev \ | ||
python3-pip \ | ||
python3-setuptools \ | ||
python3-cffi \ | ||
libxslt-dev \ | ||
libxml2-dev \ | ||
libxmlsec1-dev \ | ||
libpq-dev \ | ||
libjpeg-dev \ | ||
libgdal-dev \ | ||
wkhtmltopdf | ||
|
||
RUN --mount=type=bind,readwrite,source=.,target=/app \ | ||
pip3 install --no-cache-dir /app[dev,test] | ||
|
||
RUN groupadd -g 1000 www | ||
RUN useradd -u 1000 -ms /bin/bash -g www www |
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,36 @@ | ||
services: | ||
app: | ||
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile | ||
ports: | ||
- "${web_port}:8000" | ||
tty: true | ||
stdin_open: true | ||
command: python src/manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- ..:/app | ||
depends_on: | ||
- db | ||
environment: | ||
- DJANGO_SECRET_KEY=a-long-randomsecret-key | ||
- DJANGO_DEBUG=True | ||
- DEBUG_TOOLBAR=True | ||
- DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1 | ||
- DJANGO_DATABASE_URL=postgres://bma:hunter12@db:5432/bma | ||
- DJANGO_ADMIN_PREFIX=notadmin | ||
- DJANGO_MEDIA_ROOT=/persist/django_media_root | ||
- DJANGO_NGINX_PROXY=false | ||
- DJANGO_LOG_LEVEL=INFO | ||
- BMA_LOG_LEVEL=INFO | ||
- DJANGO_CORS_ALLOWED_ORIGINS=http://127.0.0.1:8000 | ||
- BMA_CREATOR_GROUP_NAME=creators | ||
- BMA_MODERATOR_GROUP_NAME=moderators | ||
- BMA_CURATOR_GROUP_NAME=curators | ||
db: | ||
image: postgis/postgis:14-3.3-alpine | ||
environment: | ||
- POSTGRES_USER=bma | ||
- POSTGRES_PASSWORD=hunter12 | ||
ports: | ||
- "${db_port}:5432" |