-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (68 loc) · 2.83 KB
/
Dockerfile
File metadata and controls
86 lines (68 loc) · 2.83 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
76
77
78
79
80
81
82
83
84
85
86
ARG DEBIAN_VERSION=bookworm
ARG UV_VERSION=0.7.12
ARG PY_VERSION=3.13
FROM ghcr.io/astral-sh/uv:python${PY_VERSION}-${DEBIAN_VERSION}-slim AS builder
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Disable Python downloads, because we want to use the system interpreter
# across both images. If using a managed Python version, it needs to be
# copied from the build image into the final image; see `standalone.Dockerfile`
# for an example.
ENV UV_PYTHON_DOWNLOADS=0
# Install packages needed for building the app
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl=7.88.1-10+deb12u14 \
git-svn=1:2.39.5-0+deb12u2 \
# build-essential=12.9 \
# ca-certificates=20230311 \
# make=4.3-4.1 \
unzip=6.0-28 \
# To remove the image size, it is recommended refresh the package cache as follows
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://deno.land/install.sh -o /tmp/deno_install.sh \
&& DENO_INSTALL=/usr/local sh /tmp/deno_install.sh -y \
&& rm /tmp/deno_install.sh
# Build the project in `/app`
WORKDIR /app
# Add in sound effect files and unpack them
COPY sounds.zip .
RUN unzip -u sounds.zip
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
# Then, use a final image without uv - make sure the versions match the builder!
FROM python:${PY_VERSION}-slim-${DEBIAN_VERSION}
# Run from the app dir
WORKDIR /app
# Install packages needed for running the app
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg=7:5.1.8-0+deb12u1 \
libopus0=1.3.1-3 \
# To remove the image size, it is recommended refresh the package cache as follows
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Mount persistent data directories
ENV PERSISTENT_DATA_DIR="/app/persistent"
VOLUME ["/app/persistent"]
# Copy sound effects from the builder
COPY --from=builder --chown=app:app /app/sounds /app/sounds
# Copy the app and pre-built venv from the builder - that should be all that's needed
COPY --from=builder --chown=app:app /app/src /app/src
COPY --from=builder --chown=app:app /app/.venv /app/.venv
COPY --from=builder /usr/local/bin/deno /usr/local/bin/deno
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
# Run the built app
CMD ["balaambot"]