Skip to content

Commit

Permalink
Fix building docker images (#335)
Browse files Browse the repository at this point in the history
Switch Docker images from Alpine -> Debian.
  • Loading branch information
clokep authored Mar 19, 2021
1 parent 72133ea commit d078590
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
30 changes: 12 additions & 18 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 .' \
USER sydent
WORKDIR /sydent
RUN pip install --user --upgrade pip setuptools sentry-sdk prometheus_client \
&& pip install --user . \
&& rm -rf /sydent/.cache \
&& find /sydent -name '*.pyc' -delete

#
# 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

0 comments on commit d078590

Please sign in to comment.