diff --git a/.woodpecker.yml b/.woodpecker.yml index 712721c..bce6cb8 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,38 +1,72 @@ 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 + image: woodpeckerci/plugin-docker-buildx settings: - registry: codeberg.org + 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 - # password = key or actual password - tags: latest - dockerfile: Dockerfile - + 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: plugins/docker + image: woodpeckerci/plugin-docker-buildx settings: - registry: codeberg.org + 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 - # password = key or actual password - tags: ${CI_COMMIT_SHA:0:8} \ No newline at end of file + 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