Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building docker images #335

Merged
merged 4 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#
# Step 1: Build sydent and install dependencies
#
FROM docker.io/python:3.8-alpine as builder
FROM docker.io/python:3.8-slim as builder

# Install dev packages
RUN apk add --no-cache \
build-base \
libressl-dev \
libffi-dev
RUN apt-get update && apt-get install -y \
build-essential

# Add user sydent
RUN addgroup -S -g 993 sydent \
&& adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
RUN addgroup --system --gid 993 sydent \
&& adduser --disabled-password --home /sydent --system --uid 993 --gecos sydent sydent \
&& echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd

# Copy resources
Expand All @@ -21,26 +19,22 @@ COPY --chown=sydent:sydent ["sydent", "/sydent/sydent"]
COPY --chown=sydent:sydent ["README.rst", "setup.cfg", "setup.py", "/sydent/"]

# Install dependencies
RUN cd /sydent \
&& su sydent -c 'pip install --user --upgrade pip setuptools sentry-sdk prometheus_client' \
&& su sydent -c 'pip install --user -e .' \
&& rm -rf /sydent/.cache \
&& find /sydent -name '*.pyc' -delete
USER sydent
WORKDIR /sydent
RUN pip install --user --upgrade pip setuptools sentry-sdk prometheus_client
RUN pip install --user .
RUN rm -rf /sydent/.cache
RUN find /sydent -name '*.pyc' -delete
callahad marked this conversation as resolved.
Show resolved Hide resolved

#
# Step 2: Reduce image size and layers
#

FROM docker.io/python:3.8-alpine

# Install packages
RUN apk add --no-cache \
libressl \
libffi
FROM docker.io/python:3.8-slim

# Add user sydent and create /data directory
RUN addgroup -S -g 993 sydent \
&& adduser -D --home /sydent -S -u 993 -G sydent -s /bin/ash sydent \
RUN addgroup --system --gid 993 sydent \
&& adduser --disabled-password --home /sydent --system --uid 993 --gecos sydent sydent \
&& echo "sydent:$(dd if=/dev/random bs=32 count=1 | base64)" | chpasswd \
&& mkdir /data \
&& chown sydent:sydent /data
Expand Down
1 change: 1 addition & 0 deletions changelog.d/335.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Base docker image on Debian rather than Alpine Linux.
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
name = "Bugfixes"
showcontent = true

[[tool.towncrier.type]]
directory = "docker"
name = "Updates to the Docker image"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Improved Documentation"
Expand Down