-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding full docker development (& prod) files, including docker-compose, and updating to 12-factor #1
Merged
Merged
Adding full docker development (& prod) files, including docker-compose, and updating to 12-factor #1
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be arklet_db