Skip to content

Commit eca260f

Browse files
committed
Reduce docker image size
1 parent c8cff05 commit eca260f

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

docker/Dockerfile

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ RUN cd qtoggleserver/frontend && \
2424
npm install && npx webpack --mode=production
2525

2626

27-
# Final image
27+
# Python builder image
2828

29-
FROM python:3.10.18-slim-bullseye
29+
FROM python:3.10.18-slim-bullseye AS python-builder
3030

3131
# Copy source with frontend that was just built above
3232
COPY --from=frontend-builder /tmp/build /tmp/build
@@ -38,24 +38,40 @@ COPY extra/* /usr/share/qtoggleserver/
3838

3939
RUN \
4040
# Prepare user data dir
41-
rm -rf /root/.local && ln -s /data /root/.local && \
4241
# Install OS deps
4342
apt-get update && \
44-
apt-get install --no-install-recommends -y procps less nano build-essential libglib2.0-dev bluez hostapd \
45-
dnsmasq iproute2 && \
43+
apt-get install --no-install-recommends -y build-essential libglib2.0-dev bluez && \
4644
# Prepare virtualenv
4745
pip install uv && uv virtualenv /data && . /data/bin/activate && \
4846
# Install python dependencies
4947
uv sync --active --no-dev --no-install-project --extra opt && \
5048
# Build and install our package
51-
uv build && uv pip install dist/qtoggleserver-*.tar.gz && \
52-
# Cleanups
53-
rm -r /tmp/build && \
54-
rm -rf /var/lib/apt/lists
49+
uv build && uv pip install dist/qtoggleserver-*.tar.gz
5550

51+
# Final image
52+
53+
FROM python:3.10.18-slim-bullseye
54+
55+
# Copy data dir with virtualenv that was just created above
56+
COPY --from=python-builder /data /data
5657
WORKDIR /data
5758

58-
EXPOSE 8889
59+
# Copy various stuff
60+
COPY docker/docker-entrypoint.sh /
61+
COPY extra/* /usr/share/qtoggleserver/
62+
63+
RUN \
64+
# Prepare user data dir
65+
rm -rf /root/.local && ln -s /data /root/.local && \
66+
# Install OS deps
67+
apt-get update && \
68+
apt-get install --no-install-recommends -y procps less nano bluez hostapd dnsmasq iproute2 && \
69+
# Install UV
70+
pip install uv && \
71+
# Cleanups
72+
rm -rf /var/lib/apt/lists
73+
74+
EXPOSE 8888
5975

6076
ENTRYPOINT ["/docker-entrypoint.sh"]
6177
CMD ["qtoggleserver", "-c", "/data/etc/qtoggleserver.conf"]

0 commit comments

Comments
 (0)