-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from PieterjanMontens/master
Adding full docker development (& prod) files, including docker-compose, and updating to 12-factor
- Loading branch information
Showing
10 changed files
with
413 additions
and
28 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,77 @@ | ||
# Multi-stage unique docker build script, provides both dev & prod environments | ||
|
||
# ---------------------------------------------------- | ||
# Base-image | ||
# ---------------------------------------------------- | ||
FROM python:3.9-slim-buster as common-base | ||
# Django directions: https://blog.ploetzli.ch/2020/efficient-multi-stage-build-django-docker/ | ||
# Pip on docker : https://pythonspeed.com/articles/multi-stage-docker-python/ | ||
# https://blog.mikesir87.io/2018/07/leveraging-multi-stage-builds-single-dockerfile-dev-prod/ | ||
# https://pythonspeed.com/articles/base-image-python-docker-images/ | ||
|
||
# Default environment: Dev | ||
ARG ENV=dev | ||
|
||
ENV PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONHASHSEED=random \ | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 | ||
|
||
ENV HOST=0.0.0.0 \ | ||
PORT=8000 | ||
|
||
WORKDIR /app | ||
|
||
COPY ./docker/install-packages.sh . | ||
RUN ./install-packages.sh | ||
|
||
# ---------------------------------------------------- | ||
# Install dependencies | ||
# ---------------------------------------------------- | ||
FROM common-base AS dependencies | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# apt-get install build-essential -y | ||
COPY requirements.txt /app/ | ||
|
||
RUN pip install --target /opt/packages -r requirements.txt | ||
|
||
# ---------------------------------------------------- | ||
# Copy project | ||
# ---------------------------------------------------- | ||
FROM common-base AS app-run | ||
COPY --from=dependencies /opt/packages /opt/packages | ||
ENV PYTHONPATH "${PYTHONPATH}:/opt/packages" | ||
# ENV PYTHONPATH="$PYTHONPATH:/app/lemarche:/app/config" | ||
COPY ./ark ./ark | ||
COPY ./ark_import ./ark_import | ||
COPY ./arklet ./arklet | ||
COPY ./manage.py ./manage.py | ||
COPY ./docker/entrypoint.sh ./entrypoint.sh | ||
|
||
# ---------------------------------------------------- | ||
# Run Dev | ||
# ---------------------------------------------------- | ||
FROM app-run AS dev | ||
ENV ENV="dev" \ | ||
ARKLET_DEBUG="True" | ||
|
||
CMD ["bash"] | ||
|
||
# ---------------------------------------------------- | ||
# Run Prod | ||
# ---------------------------------------------------- | ||
FROM app-run AS prod | ||
ENV ENV="prod" \ | ||
ARKLET_DEBUG="False" | ||
|
||
CMD ["./entrypoint.sh"] | ||
|
||
# # For some _real_ performance, at cost of ease of use: | ||
# FROM python:3.9-alpine as prod | ||
# ENV PATH="/opt/venv/bin:$PATH" | ||
# COPY . . | ||
# RUN apk add python3-dev build-base linux-headers pcre-dev | ||
# RUN pip install uwsgi |
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
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,35 @@ | ||
version: "3.7" | ||
|
||
services: | ||
postgres: | ||
container_name: arkled_db | ||
image: postgres:14-alpine | ||
env_file: | ||
- ./docker/env.docker.local | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
restart: always | ||
ports: | ||
- "5432:5432" | ||
|
||
arklet: | ||
container_name: arklet_django | ||
restart: always | ||
build: | ||
context: . | ||
target: dev | ||
dockerfile: ./Dockerfile | ||
command: /app/entrypoint.sh | ||
volumes: | ||
- ./ark:/app/ark | ||
- ./ark_import:/app/ark_import | ||
- ./arklet:/app/arklet | ||
env_file: | ||
- ./docker/env.docker.local | ||
ports: | ||
- "8000:8000" | ||
depends_on: | ||
- postgres | ||
|
||
volumes: | ||
postgres: |
Oops, something went wrong.