Skip to content

Commit

Permalink
Update Dockerfile and GitHub Actions for multi-architecture support
Browse files Browse the repository at this point in the history
- Modified Dockerfile to support architecture-specific artifact copying using the TARGETARCH argument.
- Enhanced the GitHub Actions workflow to dynamically set build arguments based on the target platform (amd64 or arm64).
- Ensured executable permissions for the copied artifact and set the entrypoint for the Docker container.

These changes improve the flexibility and efficiency of the Docker image build process across different architectures.
  • Loading branch information
Joachim Rosskopf committed Dec 27, 2024
1 parent c93a7d7 commit 3cd050c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: TARGETARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
build-contexts: |
amd64=./artifacts/flapi-linux-amd64
arm64=./artifacts/flapi-linux-arm64
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM ubuntu:24.04
FROM ubuntu:24.04 AS base

# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libc6 \
libstdc++6 \
Expand All @@ -8,7 +9,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=build flapi /app/flapi

# Default target architecture
ARG TARGETARCH=amd64

# Copy prebuilt artifact based on architecture
COPY ./artifacts/flapi-linux-${TARGETARCH}/flapi /app/flapi

# Ensure executable permissions
RUN chmod +x /app/flapi

# Set entrypoint
ENTRYPOINT ["/app/flapi"]

0 comments on commit 3cd050c

Please sign in to comment.