Browse Source

add architechture agnostic docker build

blah
forest 9 months ago
parent
commit
91b351a06f
3 changed files with 58 additions and 7 deletions
  1. +16
    -5
      Dockerfile
  2. +41
    -0
      build-docker.sh
  3. +1
    -2
      build.sh

+ 16
- 5
Dockerfile View File

@ -1,8 +1,19 @@
FROM alpine
COPY sequentialread-password-manager LICENSE ReadMe.md index.html.gotemplate ./
COPY static static
FROM golang:1.15.2-alpine as build
ARG GOARCH=
ARG GO_BUILD_ARGS=
EXPOSE 8073
RUN mkdir /build
WORKDIR /build
COPY . .
RUN go build -v $GO_BUILD_ARGS -o /build/sequentialread-password-manager .
CMD [ "./sequentialread-password-manager", "-headless", "true"]
FROM alpine
WORKDIR /app
COPY --from=build /build/sequentialread-password-manager /app/sequentialread-password-manager
COPY --from=build /build/index.html.gotemplate /app/index.html.gotemplate
COPY --from=build /build/static /app/static
RUN chmod +x /app/sequentialread-password-manager
ENTRYPOINT ["/app/sequentialread-password-manager"]
CMD [ "-headless", "true"]

+ 41
- 0
build-docker.sh View File

@ -0,0 +1,41 @@
#!/bin/bash -e
VERSION="1.3.0"
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/sequentialread-password-manager:$VERSION-amd64 .
docker build -f dockerbuild/Dockerfile-arm -t sequentialread/sequentialread-password-manager:$VERSION-arm .
docker build -f dockerbuild/Dockerfile-arm64 -t sequentialread/sequentialread-password-manager:$VERSION-arm64 .
docker push sequentialread/sequentialread-password-manager:$VERSION-amd64
docker push sequentialread/sequentialread-password-manager:$VERSION-arm
docker push sequentialread/sequentialread-password-manager:$VERSION-arm64
export DOCKER_CLI_EXPERIMENTAL=enabled
docker manifest create sequentialread/sequentialread-password-manager:$VERSION \
sequentialread/sequentialread-password-manager:$VERSION-amd64 \
sequentialread/sequentialread-password-manager:$VERSION-arm \
sequentialread/sequentialread-password-manager:$VERSION-arm64
docker manifest annotate --arch amd64 sequentialread/sequentialread-password-manager:$VERSION sequentialread/sequentialread-password-manager:$VERSION-amd64
docker manifest annotate --arch arm sequentialread/sequentialread-password-manager:$VERSION sequentialread/sequentialread-password-manager:$VERSION-arm
docker manifest annotate --arch arm64 sequentialread/sequentialread-password-manager:$VERSION sequentialread/sequentialread-password-manager:$VERSION-arm64
docker manifest push sequentialread/sequentialread-password-manager:$VERSION
rm -rf dockerbuild || true

+ 1
- 2
build.sh View File

@ -1,4 +1,3 @@
#!/bin/bash
GOOS=linux GOARCH=amd64 go build -v -o sequentialread-password-manager -tags netgo server.go \
&& docker build -t sequentialread/sequentialread-password-manager:1.2.0 .
go build -v -o sequentialread-password-manager -tags netgo server.go

Loading…
Cancel
Save