Skip to content

Commit b2d24e4

Browse files
committed
feat: add Docker configuration files
1 parent 98e0a67 commit b2d24e4

File tree

5 files changed

+198
-2
lines changed

5 files changed

+198
-2
lines changed

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
6+
7+
**/.DS_Store
8+
**/__pycache__
9+
**/.venv
10+
**/.classpath
11+
**/.dockerignore
12+
**/.env
13+
**/.git
14+
**/.gitignore
15+
**/.project
16+
**/.settings
17+
**/.toolstarget
18+
**/.vs
19+
**/.vscode
20+
**/*.*proj.user
21+
**/*.dbmdl
22+
**/*.jfm
23+
**/charts
24+
**/docker-compose*
25+
**/compose*
26+
**/Dockerfile*
27+
**/node_modules
28+
**/npm-debug.log
29+
**/obj
30+
**/secrets.dev.yaml
31+
**/values.dev.yaml
32+
LICENSE
33+
README.md
34+
/target/

.github/workflows/docker.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Build & Publish Images
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.*
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
env:
13+
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/interpreter-tester
14+
15+
jobs:
16+
build:
17+
name: Build Image
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- platform: linux/amd64
24+
os: ubuntu-latest
25+
- platform: linux/arm64
26+
os: ubuntu-22.04-arm
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Login to GitHub Container Registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.IMAGE_NAME }}
46+
47+
- name: Build and push image by digest
48+
id: build
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
platforms: ${{ matrix.platform }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
55+
provenance: false
56+
cache-from: type=gha
57+
cache-to: type=gha
58+
59+
- name: Export digest
60+
run: |
61+
mkdir -p /tmp/digests
62+
digest="${{ steps.build.outputs.digest }}"
63+
touch "/tmp/digests/${digest#sha256:}"
64+
echo "DIGEST=${digest#sha256:}" >> $GITHUB_ENV
65+
66+
- name: Upload digests
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: digests-${{ env.DIGEST }}
70+
path: /tmp/digests/*
71+
if-no-files-found: error
72+
retention-days: 1
73+
74+
merge:
75+
name: Merge digests
76+
runs-on: ubuntu-latest
77+
needs: build
78+
steps:
79+
- name: Download digests
80+
uses: actions/download-artifact@v4
81+
with:
82+
path: /tmp/digests
83+
pattern: digests-*
84+
merge-multiple: true
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
89+
- name: Extract metadata (tags, labels) for Docker
90+
id: meta
91+
uses: docker/metadata-action@v5
92+
with:
93+
images: ${{ env.IMAGE_NAME }}
94+
95+
- name: Login to GitHub Container Registry
96+
uses: docker/login-action@v3
97+
with:
98+
registry: ghcr.io
99+
username: ${{ github.actor }}
100+
password: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Create manifest list and push
103+
working-directory: /tmp/digests
104+
run: |
105+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
106+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
107+
108+
- name: Inspect image
109+
run: |
110+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "interpreter-tester"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2024"
55

66
[dependencies]

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/engine/reference/builder/
6+
7+
################################################################################
8+
# Base image as the foundation for the other build stages in this file.
9+
FROM lukemathwalker/cargo-chef:latest-rust-1-slim-bookworm AS chef
10+
WORKDIR /app
11+
12+
################################################################################
13+
# Create a stage for cargo chef prepare recipe.
14+
FROM chef AS planner
15+
COPY . .
16+
# Compute a lock-like file for our project
17+
RUN cargo chef prepare --recipe-path recipe.json
18+
19+
################################################################################
20+
# Create a stage for building/compiling the application.
21+
FROM chef AS builder
22+
COPY --from=planner /app/recipe.json recipe.json
23+
24+
# Build our project dependencies, not our application.
25+
RUN cargo chef cook --release --recipe-path recipe.json
26+
# Up to this point, if our dependency tree stays the same,
27+
# all layers should be cached.
28+
29+
COPY . .
30+
RUN cargo build --release --bin interpreter-tester
31+
32+
################################################################################
33+
# Create a final stage for running your application.
34+
#
35+
# The following commands copy the output from the "build" stage above and tell
36+
# the container runtime to execute it when the image is run. Ideally this stage
37+
# contains the minimal runtime dependencies for the application as to produce
38+
# the smallest image possible. This often means using a different and smaller
39+
# image than the one used for building the application, but for illustrative
40+
# purposes the "base" image is used here.
41+
FROM debian:bookworm-slim AS runtime
42+
WORKDIR /app
43+
44+
RUN addgroup --system --gid 1001 app
45+
RUN adduser --system --uid 1001 app
46+
USER app
47+
48+
# Copy the executable from the "building" stage.
49+
COPY --from=builder /app/target/release/interpreter-tester /app/
50+
51+
# What the container should run when it is started
52+
ENTRYPOINT ["/app/interpreter-tester"]

0 commit comments

Comments
 (0)