From 32e06a0244d80f84e97e2b51576364efbed0476d Mon Sep 17 00:00:00 2001 From: lauralani Date: Tue, 25 Apr 2023 21:44:47 +0200 Subject: [PATCH] add dockerfile and CI pipeline --- .woodpecker/deploy-docker.yml | 16 ++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .woodpecker/deploy-docker.yml create mode 100644 Dockerfile diff --git a/.woodpecker/deploy-docker.yml b/.woodpecker/deploy-docker.yml new file mode 100644 index 0000000..4258e49 --- /dev/null +++ b/.woodpecker/deploy-docker.yml @@ -0,0 +1,16 @@ +when: + event: + - push + +pipeline: + docker-deploy-push: + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le + repo: codeberg.org/lauralani/go-urlsh + registry: codeberg.org + tags: latest + username: lauralani + password: + from_secret: codeberg_token \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..653ef29 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.20-alpine AS dev + +COPY . /var/app +WORKDIR /var/app + +ENV GO111MODULE="on" \ + CGO_ENABLED=0 \ + GOOS=linux + +EXPOSE 80 +ENTRYPOINT ["sh"] + + +FROM dev as build + +RUN go mod download && go mod verify +RUN go build -o go-urlsh main.go +RUN chmod +x go-urlsh + + +FROM scratch AS prod + +WORKDIR /var/app +COPY --from=build /var/app/go-urlsh /var/app/ +COPY --from=build /var/app/web /var/app/web + +EXPOSE 80 +ENTRYPOINT ["/var/app/go-urlsh"] +CMD "" \ No newline at end of file