Skip to content

Commit

Permalink
Make Dockerfile support multiple TARGETARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
mat committed Nov 13, 2024
1 parent af66c90 commit b3d9f00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ FROM golang:1.23 as builder
WORKDIR /app
COPY . .

# TARGETARCH is set only by the docker buildx command - or manually
ARG TARGETARCH

# Build the command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN make build_linux_amd64
RUN make build_linux_${TARGETARCH}

# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3.20


# Have to define TARGETARCH again for the second stage
ARG TARGETARCH

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/bin/linux_amd64/iconserver /iconserver
COPY --from=builder /app/bin/linux_${TARGETARCH}/iconserver /iconserver

ENV ADDRESS=''
ENV CACHE_SIZE_MB=32
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ build_all_platforms: build_darwin_amd64 build_linux_amd64 build_linux_arm64 buil

## Docker ##
docker_build_image:
docker build --platform=linux/amd64 -t matthiasluedtke/iconserver:latest -t matthiasluedtke/iconserver:`cat VERSION` .
docker build --platform=linux/amd64 --build-arg TARGETARCH=amd64 -t matthiasluedtke/iconserver:latest -t matthiasluedtke/iconserver:`cat VERSION` .

docker_run:
docker run -p 3000:8080 --env-file docker_run.env matthiasluedtke/iconserver:latest
Expand Down

0 comments on commit b3d9f00

Please # to comment.