From b5081f2c4d8ff6efe2182c8a36c3ebdc2fd3f6db Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Fri, 3 Jun 2022 18:45:14 -0400 Subject: [PATCH] Optimize CI --- .gitlab-ci.yml | 6 ++---- Dockerfile | 10 ++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cc26ef..7a0b7a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,13 +16,11 @@ docker: - mkdir -p ~/.docker/cli-plugins - wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.8.1/buildx-v0.8.1.linux-amd64 - chmod +x ~/.docker/cli-plugins/docker-buildx - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker context create mybuilder - docker buildx create --use --name mybuilder mybuilder - - docker pull $CI_REGISTRY_IMAGE:latest || true - - docker buildx build --cache-from $CI_REGISTRY_IMAGE:latest --platform linux/amd64,linux/arm64 --push -t $CI_REGISTRY_IMAGE:latest . + - docker buildx build --platform linux/amd64,linux/arm64 --push -t $CI_REGISTRY_IMAGE:latest . deploy: image: alpine:latest @@ -32,4 +30,4 @@ deploy: - apk update && apk --no-cache add curl - wget -O - https://fly.io/install.sh | sh script: - - /root/.fly/bin/flyctl deploy --no-cache --detach + - /root/.fly/bin/flyctl deploy --detach diff --git a/Dockerfile b/Dockerfile index 57524fd..e7db2f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM golang:alpine AS build +FROM --platform=$BUILDPLATFORM golang:alpine AS build + +ARG TARGETARCH WORKDIR /src -RUN apk --no-cache add git ca-certificates -RUN git clone https://codeberg.org/video-prize-ranch/rimgo . +RUN apk --no-cache add ca-certificates +COPY . . RUN go mod download -RUN CGO_ENABLED=0 go build +RUN GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=0 go build FROM scratch as bin