From 3cf5032bc9f4af0955aa5509e8fecee09b8467bd Mon Sep 17 00:00:00 2001 From: Odyssey Date: Sat, 3 Dec 2022 20:04:26 +0100 Subject: [PATCH 1/2] not anymore Signed-off-by: Odyssey --- .woodpecker.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index 712721c..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -1,38 +0,0 @@ -pipeline: - build: - when: - event: [push, pull_request, tag] - image: golang:1.19.3-alpine - commands: - - go mod download - - go build -ldflags "-X codeberg.org/gothub/gothub/pages.Version=${CI_COMMIT_SHA:0:8}" - dockerize: - when: - branch: [main, master] - event: [push] - image: plugins/docker - settings: - registry: codeberg.org - repo: codeberg.org/gothub/gothub - username: - from_secret: user - password: - from_secret: passwd - # password = key or actual password - tags: latest - dockerfile: Dockerfile - - dockerize-dev: - when: - event: [push] - branch: [dev] - image: plugins/docker - settings: - registry: codeberg.org - repo: codeberg.org/gothub/gothub - username: - from_secret: user - password: - from_secret: passwd - # password = key or actual password - tags: ${CI_COMMIT_SHA:0:8} \ No newline at end of file From 25f57eb10917231f6704f43bd7932efdb895bc9b Mon Sep 17 00:00:00 2001 From: Odyssey Date: Sat, 3 Dec 2022 20:06:40 +0100 Subject: [PATCH 2/2] No. Signed-off-by: Odyssey --- .woodpecker.yml | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 28 ++++++++++++++----- 2 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..bce6cb8 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,72 @@ +pipeline: + dockerize: + when: + branch: [main, master] + event: [push] + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + registry: https://codeberg.org/v2 + repo: codeberg.org/gothub/gothub + platforms: linux/amd64,linux/arm64 + tag: latest + username: + from_secret: user + password: + from_secret: passwd + secrets: [user, passwd] + #dockerize-arm64: + # environment: + # - GOOS=linux + # - GOARCH=arm64 + # when: + # branch: [main, master] + # event: [push] + # image: plugins/docker + # settings: + # registry: codeberg.org + # repo: codeberg.org/gothub/gothub + # username: + # from_secret: user + # password: + # from_secret: passwd + # # password = key or actual password + # tags: arm64 + + dockerize-dev: + when: + event: [push] + branch: [dev] + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + registry: https://codeberg.org/v2 + repo: codeberg.org/gothub/gothub + platforms: linux/amd64,linux/arm64 + tag: dev + username: + from_secret: user + password: + from_secret: passwd + secrets: [user, passwd] + + #dockerize-dev-arm64: + # environment: + # - ARCH= + # - GOOS=linux + # - GOARCH=arm64 + # when: + # event: [push] + # branch: [dev] + # image: plugins/docker + # settings: + # registry: codeberg.org + # repo: codeberg.org/gothub/gothub + # username: + # from_secret: user + # password: + # from_secret: passwd + # # password = key or actual password + # tags: ${CI_COMMIT_SHA:0:8}-arm64 + # dockerfile: Dockerfile-arm64 + # # You can thank the drone docker maintainer for not providing a buildx option. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5c395b5..9df86ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,21 @@ -FROM alpine:latest -WORKDIR /gothub -COPY ./gothub . -COPY ./public/ ./public/ -COPY ./views/ ./views/ -CMD ["/bin/sh", "-c", "./gothub", "serve"] -EXPOSE 3000 \ No newline at end of file +FROM --platform=$BUILDPLATFORM golang:alpine AS build + +ARG TARGETARCH + +WORKDIR /src +RUN apk --no-cache add git +RUN git clone https://codeberg.org/gothub/gothub . + +RUN go mod download +RUN GOOS=linux GOARCH=$TARGETARCH go build -ldflags "-X codeberg.org/gothub/gothub/pages.Version=$(git rev-parse --short HEAD)" -o /src/gothub + +FROM scratch as bin + +WORKDIR /app +COPY --from=build /src/gothub . +COPY --from=build /src/views ./views +COPY --from=build /src/public ./public + +EXPOSE 3000 + +CMD ["/app/gothub", "serve"] \ No newline at end of file