Skip to content

Commit

Permalink
Build Docker image for ARM64 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed Oct 12, 2024
1 parent 9ebd6ae commit 03441d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
description: 'Docker tag'
required: true
type: string
default: 'latest'
default: 'preview'

jobs:
build:
Expand All @@ -34,6 +34,10 @@ jobs:
run: echo "REPOSITORY_LC=${REPOSITORY,,}" >> $GITHUB_ENV
env:
REPOSITORY: '${{ github.repository }}'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub registry
Expand All @@ -44,5 +48,6 @@ jobs:
registry: ghcr.io
- uses: docker/build-push-action@v6
with:
push: true
push: false
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ env.DOCKER_TAG }}
platforms: linux/amd64,linux/arm64
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@ ARG RUNTIME_IMAGE=ubuntu:noble

# Builder image
FROM ${BUILDER_IMAGE} AS builder
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
libxml2-dev \
&& rm -r /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y libcurl4-openssl-dev libxml2-dev
RUN rm -r /var/lib/apt/lists/*
WORKDIR /workdir/
COPY Plugins Plugins/
COPY Source Source/
COPY Tests Tests/
COPY Package.* ./

RUN echo `swift build $SWIFT_FLAGS --show-bin-path`
RUN swift package update
ARG SWIFT_FLAGS="-c release -Xswiftc -static-stdlib -Xlinker -l_CFURLSessionInterface -Xlinker -l_CFXMLInterface -Xlinker -lcurl -Xlinker -lxml2 -Xswiftc -I. -Xlinker -fuse-ld=lld -Xlinker -L/usr/lib/swift/linux"
ARG SWIFT_FLAGS="-c debug -Xswiftc -static-stdlib -Xlinker -l_CFURLSessionInterface -Xlinker -l_CFXMLInterface -Xlinker -lcurl -Xlinker -lxml2 -Xswiftc -I. -Xlinker -fuse-ld=lld -Xlinker -L/usr/lib/swift/linux"
RUN swift build $SWIFT_FLAGS --product swiftlint
RUN mv `swift build $SWIFT_FLAGS --show-bin-path`/swiftlint /usr/bin
RUN ls -l `swift build $SWIFT_FLAGS --show-bin-path`
RUN mv `swift build $SWIFT_FLAGS --show-bin-path`/swiftlint /workdir

# Runtime image
FROM ${RUNTIME_IMAGE}
LABEL org.opencontainers.image.source=https://github.com/realm/SwiftLint
RUN apt-get update && apt-get install -y \
libcurl4 \
libxml2 \
&& rm -r /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y libcurl4 libxml2
RUN rm -r /var/lib/apt/lists/*
COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib
COPY --from=builder /usr/lib/swift/host/libSwiftBasicFormat.so /usr/lib
COPY --from=builder /usr/lib/swift/host/libSwiftCompilerPluginMessageHandling.so /usr/lib
Expand Down Expand Up @@ -55,7 +53,7 @@ COPY --from=builder /usr/lib/swift/linux/libswiftDispatch.so /usr/lib
COPY --from=builder /usr/lib/swift/linux/libswiftGlibc.so /usr/lib
COPY --from=builder /usr/lib/swift/linux/libswiftSynchronization.so /usr/lib
COPY --from=builder /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so /usr/lib
COPY --from=builder /usr/bin/swiftlint /usr/bin
COPY --from=builder /workdir/swiftlint /usr/bin

RUN swiftlint version
RUN echo "_ = 0" | swiftlint --use-stdin
Expand Down

0 comments on commit 03441d8

Please sign in to comment.