Browse Source

fix docker build caching and add arm64

master
forest 11 months ago
parent
commit
d68d97256e
6 changed files with 45 additions and 18 deletions
  1. +3
    -0
      .dockerignore
  2. +1
    -0
      .gitignore
  3. +10
    -7
      Dockerfile
  4. +27
    -10
      build-docker.sh
  5. +2
    -1
      build.sh
  6. +2
    -0
      config/ReadMe.md

+ 3
- 0
.dockerignore View File

@ -0,0 +1,3 @@
build
dockerbuild
localbuild.sh

+ 1
- 0
.gitignore View File

@ -1,2 +1,3 @@
build
dockerbuild
localbuild.sh

+ 10
- 7
Dockerfile View File

@ -1,22 +1,25 @@
FROM golang:1.15.2-alpine as build
ARG GOARCH=amd64
ARG GOARCH=
ARG GO_BUILD_ARGS=
RUN apk add --update --no-cache ca-certificates git
# Threshold has its own certificates -- it doesn't need the public internet ones
# RUN apk add --update --no-cache ca-certificates git
RUN mkdir /build
WORKDIR /build
COPY . .
RUN go build -v $GO_BUILD_ARGS -o /build/threshold main.go
FROM scratch
FROM alpine
WORKDIR /threshold
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /build/threshold /threshold
# COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /build/threshold /threshold/threshold
RUN mkdir -p /threshold/config
# NOTE: the user will have to mount the config file & any required TLS certs/keys
# NOTE: the user will have to mount the config file & any required TLS certs/keys into /opt/threshold/
# as well as override the default command (-mode server)
ENTRYPOINT ["/threshold"]
ENTRYPOINT ["/threshold/threshold"]
CMD ["-mode", "server"]

+ 27
- 10
build-docker.sh View File

@ -1,18 +1,35 @@
#!/bin/bash -e
docker build --build-arg "GOARCH=amd64" -t sequentialread/threshold:0.0.0-amd64 .
docker build --build-arg "GOARCH=arm" -t sequentialread/threshold:0.0.0-arm .
VERSION="0.0.1"
docker push sequentialread/threshold:0.0.0-amd64
docker push sequentialread/threshold:0.0.0-arm
rm -rf dockerbuild || true
mkdir dockerbuild
cp Dockerfile dockerbuild/Dockerfile-amd64
cp Dockerfile dockerbuild/Dockerfile-arm
cp Dockerfile 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/threshold:$VERSION-amd64 .
docker build -f dockerbuild/Dockerfile-arm -t sequentialread/threshold:$VERSION-arm .
docker build -f dockerbuild/Dockerfile-arm64 -t sequentialread/threshold:$VERSION-arm64 .
docker push sequentialread/threshold:$VERSION-amd64
docker push sequentialread/threshold:$VERSION-arm
docker push sequentialread/threshold:$VERSION-arm64
export DOCKER_CLI_EXPERIMENTAL=enabled
docker manifest create sequentialread/threshold:0.0.0 \
sequentialread/threshold:0.0.0-amd64 \
sequentialread/threshold:0.0.0-arm
docker manifest create sequentialread/threshold:$VERSION \
sequentialread/threshold:$VERSION-amd64 \
sequentialread/threshold:$VERSION-arm \
sequentialread/threshold:$VERSION-arm64
docker manifest annotate --arch amd64 sequentialread/threshold:0.0.0 sequentialread/threshold:0.0.0-amd64
docker manifest annotate --arch arm sequentialread/threshold:0.0.0 sequentialread/threshold:0.0.0-arm
docker manifest annotate --arch amd64 sequentialread/threshold:$VERSION sequentialread/threshold:$VERSION-amd64
docker manifest annotate --arch arm sequentialread/threshold:$VERSION sequentialread/threshold:$VERSION-arm
docker manifest annotate --arch arm64 sequentialread/threshold:$VERSION sequentialread/threshold:$VERSION-arm64
docker manifest push sequentialread/threshold:0.0.0
docker manifest push sequentialread/threshold:$VERSION

+ 2
- 1
build.sh View File

@ -45,4 +45,5 @@ function build() {
}
build arm
build amd64
build amd64
build arm64

+ 2
- 0
config/ReadMe.md View File

@ -0,0 +1,2 @@
Place a config file here

Loading…
Cancel
Save