Skip to content

Commit 3e81d42

Browse files
committed
👷 Boring docker stuff
1 parent 2bbf7de commit 3e81d42

File tree

5 files changed

+434
-239
lines changed

5 files changed

+434
-239
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.github/
22
.gitignore
33
config.example.yaml
4-
poetry.lock
5-
pyproject.toml
64
readme.md
75
renovate.json

Dockerfile

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
# Copyright (c) NiceBots.xyz
22
# SPDX-License-Identifier: MIT
33

4-
# For more information, please refer to https://aka.ms/vscode-docker-python
5-
FROM python:3.12-slim-bookworm
4+
ARG PYTHON_VERSION=3.12
5+
ARG NODE_VERSION=20
6+
FROM python:${PYTHON_VERSION}-slim-bookworm AS python-base
67

7-
# Keeps Python from generating .pyc files in the container
88
ENV PYTHONDONTWRITEBYTECODE=1
9-
10-
# Turns off buffering for easier container logging
119
ENV PYTHONUNBUFFERED=1
1210

13-
# we move to the app folder and run the pip install command
11+
RUN pip install -U pdm
12+
ENV PDM_CHECK_UPDATE=false
13+
1414
WORKDIR /app
15+
COPY src pyproject.toml pdm.lock ./
1516

16-
ENV PYTHONUNBUFFERED 1
17-
ENV PYTHONDONTWRITEBYTECODE 1
17+
RUN pdm export --prod -o requirements.txt
1818

19-
# we copy just the requirements.txt first to leverage Docker cache
20-
COPY requirements.txt .
19+
FROM python:${PYTHON_VERSION}-slim-bookworm AS app
2120

22-
# Install pip requirements
23-
RUN pip install -r requirements.txt
21+
ENV PYTHONDONTWRITEBYTECODE=1
22+
ENV PYTHONUNBUFFERED=1
23+
24+
WORKDIR /app
2425

25-
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
2626
RUN adduser -u 6392 --disabled-password --gecos "" appuser && chown -R appuser /app
27-
USER appuser
2827

29-
# We copy the rest of the codebase into the image
30-
COPY ./ /app/
28+
COPY --from=python-base --chown=appuser /app/requirements.txt ./
29+
COPY src/ ./src
30+
COPY LICENSE ./
31+
32+
RUN pip install -r requirements.txt --require-hashes
33+
USER appuser
3134

32-
# We run the application
33-
CMD ["python", "src"]
35+
CMD ["python", "src"]

0 commit comments

Comments
 (0)