Skip to content

Commit

Permalink
Split into slim and distroless variants
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmarble committed Jan 14, 2024
1 parent 32cedbf commit c7c5407
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/distroless-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Container image
"on":
push:
branches:
- 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,distroless
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: Dockerfile.distroless
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,slim
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: Dockerfile.slim
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
1 change: 1 addition & 0 deletions Dockerfile → Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY --from=builder /usr/lib/x86_64-linux-gnu/libedit.so.2 /usr/lib/x86_64-linux
COPY --from=builder /usr/lib/x86_64-linux-gnu/libbsd.so.0 /usr/lib/x86_64-linux-gnu/libbsd.so.0
COPY --from=builder /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.6
COPY --from=builder /usr/lib/x86_64-linux-gnu/libmd.so.0 /usr/lib/x86_64-linux-gnu/libmd.so.0
COPY --from=builder /lib/terminfo /lib/terminfo

COPY --from=builder /simh/BIN/pdp11 /bin/pdp11
ENTRYPOINT ["/bin/pdp11"]
30 changes: 30 additions & 0 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM docker.io/library/debian:12.4-slim as builder

RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential=12.9 \
ca-certificates=20230311 \
git=1:2.39.2-1.1 \
sudo=1.9.13p3-1+deb12u1
# Not removing cache here because the deps.sh script can use it.
# The cache will not be in the final stage of the image anyway.

RUN mkdir /simh \
&& git clone --depth 1 https://github.com/open-simh/simh.git /simh \
&& /simh/.travis/deps.sh linux \
&& /simh/cmake/cmake-builder.sh --novideo --noinstall --parallel --target pdp11

FROM docker.io/library/debian:12.4-slim

RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get install -y --no-install-recommends \
libvdeplug2=4.0.1-4 \
libpcre3=2:8.39-15 \
libedit2=3.1-20221030-2 \
libbsd0=0.11.7-2 \
libmd0=1.0.4-2 \
ncurses-base=6.4-4 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /simh/BIN/pdp11 /bin/pdp11
CMD ["/bin/pdp11"]

0 comments on commit c7c5407

Please sign in to comment.