added Dockerstuff for dev and prod using traefik
This commit is contained in:
parent
17c06d1eaa
commit
879366eb95
8 changed files with 221 additions and 0 deletions
18
app/Dockerfile
Normal file
18
app/Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
# app/Dockerfile
|
||||
|
||||
# pull the official docker image
|
||||
FROM python:3.11.2-slim
|
||||
|
||||
# set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# set env variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# copy project
|
||||
COPY . .
|
62
app/Dockerfile.prod
Normal file
62
app/Dockerfile.prod
Normal file
|
@ -0,0 +1,62 @@
|
|||
###########
|
||||
# BUILDER #
|
||||
###########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
# set work directory
|
||||
WORKDIR /app
|
||||
|
||||
# set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gcc
|
||||
|
||||
# lint
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install flake8==6.0.0
|
||||
COPY . .
|
||||
RUN flake8 --ignore=E501,F401 .
|
||||
|
||||
# install python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
|
||||
|
||||
|
||||
#########
|
||||
# FINAL #
|
||||
#########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# create directory for the app user
|
||||
RUN mkdir -p /home/app
|
||||
|
||||
# create the app user
|
||||
RUN addgroup --system app && adduser --system --group app
|
||||
|
||||
# create the appropriate directories
|
||||
ENV HOME=/home/app
|
||||
ENV APP_HOME=/home/app/web
|
||||
RUN mkdir $APP_HOME
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
# install dependencies
|
||||
COPY --from=builder /usr/src/app/wheels /wheels
|
||||
COPY --from=builder /app/requirements.txt .
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache /wheels/*
|
||||
|
||||
# copy project
|
||||
COPY . $APP_HOME
|
||||
|
||||
# chown all the files to the app user
|
||||
RUN chown -R app:app $APP_HOME
|
||||
|
||||
# change to the app user
|
||||
USER app
|
Loading…
Add table
Add a link
Reference in a new issue