forked from modmail-dev/Modmail
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from root to app user for Docker
- Loading branch information
1 parent
13ae200
commit 2cba222
Showing
2 changed files
with
16 additions
and
11 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
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 |
---|---|---|
@@ -1,28 +1,27 @@ | ||
FROM python:3.10-alpine as base | ||
|
||
RUN apk add wget git cairo-dev cairo cairo-tools \ | ||
RUN apk update && apk add git cairo-dev cairo cairo-tools \ | ||
# pillow dependencies | ||
jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev | ||
|
||
FROM base AS python-deps | ||
|
||
# Install pipenv and compilation dependencies | ||
RUN apk update && apk add --virtual build-dependencies build-base gcc libffi-dev | ||
RUN pip install pipenv | ||
RUN apk add --virtual build-dependencies build-base gcc libffi-dev | ||
|
||
# Install python dependencies in /.venv | ||
COPY Pipfile Pipfile.lock / | ||
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy | ||
RUN pip install pipenv && PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy | ||
|
||
FROM base AS runtime | ||
|
||
# Copy virtual env from python-deps stage | ||
COPY --from=python-deps /.venv /.venv | ||
ENV PATH="/.venv/bin:$PATH" | ||
|
||
# Install application into container | ||
ENV USING_DOCKER yes | ||
COPY . . | ||
COPY . /modmail | ||
WORKDIR /modmail | ||
|
||
# Run the application | ||
CMD ["python", "-m", "bot"] | ||
|
||
RUN adduser --disabled-password --gecos '' app && \ | ||
chown -R app /modmail && chown -R app /.venv | ||
USER app |