Skip to content

Commit a7dcee6

Browse files
committed
Refactor Dockerfile and build-migrations.yaml to use build arguments for architecture
1 parent d31fb69 commit a7dcee6

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.github/workflows/build-migrations.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ jobs:
138138
outputs: type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
139139
cache-from: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
140140
cache-to: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ matrix.platform }}
141-
141+
build-args: |
142+
ARCH=${{ env.PLATFORM_PAIR }}
142143
143144
- name: Export digest
144145
# This step exports the digest of the built image to a file.

migrate/Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
FROM debian:bookworm-slim as builder
2-
3-
# Set the ARCH variable by executing a command on the host.
4-
RUN --mount=type=bind,source=/etc/os-release,target=/etc/os-release,readonly \
5-
ARCH=$(dpkg --print-architecture) && \
6-
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.17.1/migrate.linux-$ARCH.tar.gz | tar xvz && \
7-
mv migrate /usr/bin/
8-
9-
# Final stage
101
FROM debian:bookworm-slim
112

12-
COPY --from=builder /usr/bin/migrate /usr/bin/migrate
3+
ARG ARCH="linux-amd64"
4+
5+
RUN apt-get update -y && \
6+
apt-get install -y curl && \
7+
rm -rf /var/lib/apt/lists/* && \
8+
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.17.1/migrate.${ARCH}.tar.gz | tar xvz && \
9+
mv migrate /usr/bin/
1310

1411
COPY bin /usr/local/bin
12+
1513
COPY ./migrations /migrations
1614

1715
ENV MYSQL_DB=""
1816

19-
CMD ["up"]
17+
CMD ["up"]

0 commit comments

Comments
 (0)