-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (56 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
75 lines (56 loc) · 2.07 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM ghcr.io/stephanlensky/swayvnc-chrome:latest
ARG ENABLE_XWAYLAND
# install xwayland
RUN if [ "$ENABLE_XWAYLAND" = "true" ]; then \
apt-get update && \
apt-get -y install xwayland && \
Xwayland -version && \
echo "Xwayland installed."; \
else \
echo "Xwayland installation skipped."; \
fi
# set DISPLAY for xwayland
RUN if [ "$ENABLE_XWAYLAND" = "true" ]; then \
sed -i '/^export XDG_RUNTIME_DIR/i \
export DISPLAY=${DISPLAY:-:0}' \
/entrypoint_user.sh; \
fi
# add `xwayland enable` to sway config
RUN if [ "$ENABLE_XWAYLAND" = "true" ]; then \
sed -i 's/xwayland disable/xwayland enable/' \
/home/$DOCKER_USER/.config/sway/config; \
fi
ARG SWAY_UNSUPPORTED_GPU
# add `--unsupported-gpu` flag to sway command
RUN if [ "$SWAY_UNSUPPORTED_GPU" = "true" ]; then \
sed -i 's/sway &/sway --unsupported-gpu \&/' /entrypoint_user.sh; \
fi
ENV PYTHONUNBUFFERED=1
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
# Make directory for the app
RUN mkdir /app
RUN chown $DOCKER_USER:$DOCKER_USER /app
# Switch to the non-root user
USER $DOCKER_USER
# Set the working directory
WORKDIR /app
# Install python
RUN uv python install 3.13
# Install the Python project's dependencies using the lockfile and settings
COPY --chown=$DOCKER_USER:$DOCKER_USER pyproject.toml uv.lock /app/
RUN --mount=type=cache,target=/home/$DOCKER_USER/.cache/uv,uid=$PUID,gid=$PGID \
uv sync --frozen --no-install-project
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
COPY --chown=$DOCKER_USER:$DOCKER_USER . /app
# Add binaries from the project's virtual environment to the PATH
ENV PATH="/app/.venv/bin:$PATH"
# Sync the project's dependencies and install the project
RUN --mount=type=cache,target=/home/$DOCKER_USER/.cache/uv,uid=$PUID,gid=$PGID \
uv sync --frozen
USER root
# Pass custom command to entrypoint script provided by the base image
ENTRYPOINT ["/entrypoint.sh"]
CMD [".venv/bin/python", "-m" ,"app.main"]