-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: slim down the docker container (#60)
Co-authored-by: Ushie <[email protected]>
- Loading branch information
Showing
5 changed files
with
36 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea | ||
.devcontainer | ||
.git | ||
.gitignore | ||
.github | ||
.vscode |
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,14 +1,34 @@ | ||
FROM python:3.11-slim | ||
## Build dependencies | ||
FROM python:3.11-slim as dependencies | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends gcc \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN python -m venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
ARG GITHUB_TOKEN | ||
ENV GITHUB_TOKEN $GITHUB_TOKEN | ||
COPY requirements.txt . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
## Image | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
COPY --from=dependencies /opt/venv /opt/venv | ||
COPY . . | ||
|
||
RUN apt update && \ | ||
apt-get install build-essential libffi-dev libssl-dev openssl --no-install-recommends -y \ | ||
&& pip install --no-cache-dir -r requirements.txt | ||
CMD docker/run-backend.sh | ||
HEALTHCHECK CMD docker/run-healthcheck.sh | ||
|
||
CMD [ "python3", "-m" , "sanic", "app:app", "--fast", "--access-logs", "--motd", "--noisy-exceptions", "-H", "0.0.0.0"] | ||
EXPOSE 8000 |
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 @@ | ||
python3 -m sanic /usr/src/app --fast --access-logs --motd --noisy-exceptions -H 0.0.0.0 |
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 @@ | ||
curl --fail http://0.0.0.0:8000/docs |