Skip to content

Commit c65fb19

Browse files
committed
Add Dockerfiles
1 parent 0b937c2 commit c65fb19

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM python:3.12-slim
2+
3+
RUN groupadd -r greybook && useradd -r -g greybook greybook
4+
5+
WORKDIR /home/greybook
6+
RUN apt-get update
7+
RUN apt-get install -y gcc g++
8+
9+
COPY requirements.txt requirements.txt
10+
RUN python3 -m venv venv
11+
RUN venv/bin/pip install -r requirements.txt
12+
RUN venv/bin/pip install gunicorn
13+
14+
COPY greybook greybook
15+
COPY migrations migrations
16+
COPY logs logs
17+
COPY uploads uploads
18+
COPY app.py .
19+
20+
ENV FLASK_APP app
21+
ENV FLASK_CONFIG production
22+
23+
RUN chown -R greybook:greybook .
24+
USER greybook
25+
26+
EXPOSE 5000
27+
RUN venv/bin/flask db upgrade
28+
ENTRYPOINT ["venv/bin/gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "app:app"]

Dockerfile.multi-stage

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# stage 1: build
2+
ARG base_image=python:3.12-slim
3+
FROM ${base_image} AS build
4+
5+
WORKDIR /home/greybook
6+
RUN apt-get update && apt-get install -y gcc g++
7+
8+
# install dependencies
9+
COPY requirements.txt requirements.txt
10+
RUN python3 -m venv venv
11+
RUN venv/bin/pip install -r requirements.txt
12+
RUN venv/bin/pip install gunicorn
13+
14+
# stage 2: production
15+
FROM ${base_image}
16+
17+
RUN groupadd -r greybook && useradd -r -g greybook greybook
18+
WORKDIR /home/greybook
19+
20+
# copy the installed dependencies from the previous stage
21+
COPY --from=build /home/greybook/venv/ venv/
22+
23+
# copy the application source code from the previous stage
24+
COPY greybook greybook
25+
COPY migrations migrations
26+
COPY logs logs
27+
COPY uploads uploads
28+
COPY app.py .
29+
30+
ENV FLASK_APP app
31+
ENV FLASK_CONFIG production
32+
33+
RUN chown -R greybook:greybook .
34+
USER greybook
35+
36+
EXPOSE 5000
37+
RUN venv/bin/flask db upgrade
38+
ENTRYPOINT ["venv/bin/gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "app:app"]

0 commit comments

Comments
 (0)