Browse Source

add architechture agnostic docker build

master
forest 11 months ago
parent
commit
229e705eee
2 changed files with 56 additions and 0 deletions
  1. +15
    -0
      Dockerfile
  2. +41
    -0
      build-docker.sh

+ 15
- 0
Dockerfile View File

@ -0,0 +1,15 @@
FROM golang:1.15.2-alpine as build
ARG GOARCH=
ARG GO_BUILD_ARGS=
RUN mkdir /build
WORKDIR /build
COPY . .
RUN go build -v $GO_BUILD_ARGS -o /build/webclip .
FROM alpine
WORKDIR /app
COPY --from=build /build/webclip /app/webclip
RUN chmod +x /app/webclip
ENTRYPOINT ["/app/webclip"]

+ 41
- 0
build-docker.sh View File

@ -0,0 +1,41 @@
#!/bin/bash -e
VERSION="0.0.1"
rm -rf dockerbuild || true
mkdir dockerbuild
cp Dockerfile dockerbuild/Dockerfile-amd64
cp Dockerfile dockerbuild/Dockerfile-arm
cp Dockerfile dockerbuild/Dockerfile-arm64
sed -E 's|FROM alpine|FROM amd64/alpine|' -i dockerbuild/Dockerfile-amd64
sed -E 's|FROM alpine|FROM arm32v7/alpine|' -i dockerbuild/Dockerfile-arm
sed -E 's|FROM alpine|FROM arm64v8/alpine|' -i dockerbuild/Dockerfile-arm64
sed -E 's/GOARCH=/GOARCH=amd64/' -i dockerbuild/Dockerfile-amd64
sed -E 's/GOARCH=/GOARCH=arm/' -i dockerbuild/Dockerfile-arm
sed -E 's/GOARCH=/GOARCH=arm64/' -i dockerbuild/Dockerfile-arm64
docker build -f dockerbuild/Dockerfile-amd64 -t sequentialread/webclip:$VERSION-amd64 .
docker build -f dockerbuild/Dockerfile-arm -t sequentialread/webclip:$VERSION-arm .
docker build -f dockerbuild/Dockerfile-arm64 -t sequentialread/webclip:$VERSION-arm64 .
docker push sequentialread/webclip:$VERSION-amd64
docker push sequentialread/webclip:$VERSION-arm
docker push sequentialread/webclip:$VERSION-arm64
export DOCKER_CLI_EXPERIMENTAL=enabled
docker manifest create sequentialread/webclip:$VERSION \
sequentialread/webclip:$VERSION-amd64 \
sequentialread/webclip:$VERSION-arm \
sequentialread/webclip:$VERSION-arm64
docker manifest annotate --arch amd64 sequentialread/webclip:$VERSION sequentialread/webclip:$VERSION-amd64
docker manifest annotate --arch arm sequentialread/webclip:$VERSION sequentialread/webclip:$VERSION-arm
docker manifest annotate --arch arm64 sequentialread/webclip:$VERSION sequentialread/webclip:$VERSION-arm64
docker manifest push sequentialread/webclip:$VERSION
rm -rf dockerbuild || true

Loading…
Cancel
Save