Skip to content

Commit d46d947

Browse files
committed
feat: docker multi-arch support
- linux/amd64 - linux/386 - linux/arm64 - linux/arm/v7 - linux/arm/v6
1 parent 4fe4a5f commit d46d947

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

.github/workflows/devel.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ jobs:
1212
matrix:
1313
arch:
1414
- linux/amd64
15-
# - linux/arm64
16-
# - linux/arm/v7
17-
# - linux/arm/v6
15+
- linux/386
16+
- linux/arm64
17+
- linux/arm/v7
18+
- linux/arm/v6
1819
runs-on: ubuntu-20.04
1920
steps:
2021
-

.github/workflows/release.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
-
1313
name: Checkout
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515
-
1616
name: Set up QEMU
1717
uses: docker/setup-qemu-action@v1
@@ -45,8 +45,7 @@ jobs:
4545
with:
4646
push: true
4747
context: .
48-
platforms: linux/amd64
49-
# platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
48+
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
5049
file: Dockerfile
5150
tags: ${{ steps.meta.outputs.tags }}
5251
build-args: |

Dockerfile

+28-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
FROM alpine:3.15
1+
FROM --platform=$BUILDPLATFORM alpine:3.16 as build
2+
3+
ARG TARGETPLATFORM
4+
ARG VERSION=0.0.0
5+
ENV VERSION=${VERSION}
6+
ARG ENVE_VERSION=1.4.0
7+
8+
RUN apk --no-cache add ca-certificates tzdata
9+
RUN set -ex; \
10+
case "$TARGETPLATFORM" in \
11+
"linux/amd64") target='amd64' ;; \
12+
"linux/arm64") target='arm64' ;; \
13+
"linux/386") target='i386' ;; \
14+
"linux/arm/v7") target='armv7' ;; \
15+
"linux/arm/v6") target='armv6' ;; \
16+
*) echo >&2 "error: unsupported $TARGETPLATFORM architecture"; exit 1 ;; \
17+
esac; \
18+
wget --quiet -O /tmp/enve.tar.gz \
19+
"https://github.com/joseluisq/enve/releases/download/v${ENVE_VERSION}/enve_v${ENVE_VERSION}_linux_${target}.tar.gz"; \
20+
tar xzvf /tmp/enve.tar.gz -C /usr/local/bin enve; \
21+
enve -v; \
22+
chmod +x /usr/local/bin/enve; \
23+
true
24+
25+
FROM alpine:3.16
226

327
ARG VERSION=0.0.0
428
ENV VERSION=${VERSION}
@@ -10,7 +34,6 @@ LABEL version="${VERSION}" \
1034
# Dependencies
1135
ENV BUILD_DEPS="gettext"
1236
ENV RUNTIME_DEPS="libintl"
13-
ARG ENVE_VERSION=1.4.0
1437

1538
# Custom user
1639
ARG USER_NAME
@@ -26,20 +49,17 @@ RUN set -eux \
2649
&& apk add --virtual build_deps $BUILD_DEPS \
2750
&& cp /usr/bin/envsubst /usr/local/bin/envsubst \
2851
&& apk del build_deps \
29-
&& wget --quiet -O /tmp/enve.tar.gz \
30-
"https://github.com/joseluisq/enve/releases/download/v${ENVE_VERSION}/enve_v${ENVE_VERSION}_linux_amd64.tar.gz" \
31-
&& tar xzvf /tmp/enve.tar.gz -C /usr/local/bin enve \
32-
&& enve -v \
33-
&& rm -rf /tmp/enve.tar.gz \
34-
&& chmod +x /usr/local/bin/enve \
3552
&& true
3653

54+
COPY --from=build /usr/local/bin/enve /usr/local/bin/
55+
3756
COPY ./__mysqldump.sh /usr/local/bin/__mysqldump.sh
3857
COPY ./mysql_exporter /usr/local/bin/mysql_exporter
3958
COPY ./__mysqlimport.sh /usr/local/bin/__mysqlimport.sh
4059
COPY ./mysql_importer /usr/local/bin/mysql_importer
4160

4261
RUN set -eux \
62+
&& enve -v \
4363
&& chmod +x /usr/local/bin/__mysqldump.sh \
4464
&& chmod +x /usr/local/bin/__mysqlimport.sh \
4565
&& chmod +x /usr/local/bin/mysql_exporter \

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
build:
2-
@docker build -t alpine-mysql-client:latest -f Dockerfile .
3-
.PHONY: build
1+
buildx:
2+
@docker buildx build \
3+
--network=host \
4+
--build-arg VERSION=0.0.0 \
5+
-t alpine-mysql-client:latest -f Dockerfile .
6+
.PHONY: buildx
47

58
export:
69
@docker run --rm -it \

0 commit comments

Comments
 (0)