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