diff --git a/.gitignore b/.gitignore index 4f1f4eb..bb36f1d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,9 @@ # Woodpecker CI !.woodpecker/* +# Docker build files +!Dockerfile +!Dockerfile.* + # ...even if they are in subdirectories !*/ diff --git a/.woodpecker/deploy-docker.yml b/.woodpecker/deploy-docker.yml new file mode 100644 index 0000000..d88c28b --- /dev/null +++ b/.woodpecker/deploy-docker.yml @@ -0,0 +1,35 @@ +when: + - event: [pull_request, tag] + + +steps: + docker-deploy-pr: + when: + - event: pull_request + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 + repo: adoralaura/adoralaura + registry: https://index.docker.io/v1/ + tag: pr-${CI_COMMIT_PULL_REQUEST} + username: adoralaura + password: + from_secret: dockerhub_token + + + docker-deploy-tag: + when: + event: tag + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 + repo: adoralaura/app-name + registry: https://index.docker.io/v1/ + auto_tag: true + username: adoralaura + password: + from_secret: dockerhub_token + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6cc2a8c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM golang:1.22-bullseye 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 DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes ca-certificates +RUN go mod download && go mod verify +RUN go build -o app-name main.go +RUN chmod +x app-name + + +FROM gcr.io/distroless/static-debian12 AS prod + +WORKDIR /app +COPY --from=build /var/app/app-name /bin/ + +LABEL maintainer="Adora Laura Kalb " + +EXPOSE 8080 +ENTRYPOINT ["/bin/app-name"]