-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
52 lines (37 loc) · 1.25 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
ARG PY_VERSION=3.12
# Stage 1: Install dependencies and build tools
FROM python:$PY_VERSION AS setup
# Set the working directory in the container
WORKDIR /app
# Copy the source code, pyproject.toml, .git file to the container
COPY . .
# Install build dependencies
RUN <<EOF
pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir .[build]
EOF
# dev container build
# docs: https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md
FROM mcr.microsoft.com/vscode/devcontainers/python:${PY_VERSION} AS dev
ARG NODE_VERSION="none"
# Build the binaries
FROM setup AS installer
RUN pyinstaller scripts/installer.spec
# use scratch for easy exports
FROM scratch AS bin
COPY --from=installer /app/dist/duploctl /duploctl
# Build the package
FROM setup AS builder
RUN python -m build --no-isolation
# Stage 2: Install the package in a slimmer container
FROM python:$PY_VERSION-slim AS runner
# Set the working directory in the container
WORKDIR /app
# Copy the built package from the previous stage
COPY --from=builder /app/dist ./dist/
# Install the package using pip
RUN pip install --no-cache-dir ./dist/*.whl && \
rm -rf ./dist
# Set the entrypoint command for the container
ENTRYPOINT ["duploctl"]
CMD [ "version" ]