Skip to content
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

Add Dockerfiles #26

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.12-slim

RUN groupadd -r greybook && useradd -r -g greybook greybook

WORKDIR /home/greybook
RUN apt-get update
RUN apt-get install -y gcc g++

COPY requirements.txt requirements.txt
RUN python3 -m venv venv
RUN venv/bin/pip install -r requirements.txt
RUN venv/bin/pip install gunicorn

COPY greybook greybook
COPY migrations migrations
COPY logs logs
COPY uploads uploads
COPY app.py .

ENV FLASK_APP app
ENV FLASK_CONFIG production

RUN chown -R greybook:greybook .
USER greybook

EXPOSE 5000
RUN venv/bin/flask db upgrade
ENTRYPOINT ["venv/bin/gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
38 changes: 38 additions & 0 deletions Dockerfile.multi-stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# stage 1: build
ARG base_image=python:3.12-slim
FROM ${base_image} AS build

WORKDIR /home/greybook
RUN apt-get update && apt-get install -y gcc g++

# install dependencies
COPY requirements.txt requirements.txt
RUN python3 -m venv venv
RUN venv/bin/pip install -r requirements.txt
RUN venv/bin/pip install gunicorn

# stage 2: production
FROM ${base_image}

RUN groupadd -r greybook && useradd -r -g greybook greybook
WORKDIR /home/greybook

# copy the installed dependencies from the previous stage
COPY --from=build /home/greybook/venv/ venv/

# copy the application source code from the previous stage
COPY greybook greybook
COPY migrations migrations
COPY logs logs
COPY uploads uploads
COPY app.py .

ENV FLASK_APP app
ENV FLASK_CONFIG production

RUN chown -R greybook:greybook .
USER greybook

EXPOSE 5000
RUN venv/bin/flask db upgrade
ENTRYPOINT ["venv/bin/gunicorn", "-b", ":5000", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
2 changes: 1 addition & 1 deletion greybook/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def init(username, password):
about='Anything about you.'
)
db.session.add(admin)
click.echo('Created the temporary administrator account.')
click.echo('Created the administrator account.')

category = db.session.execute(select(Category)).scalar()
if category is None:
Expand Down
Loading
Loading