From 31aae0b2238c84b6a57dbd44c498ce69d9eeefe2 Mon Sep 17 00:00:00 2001 From: "kalle (jag)" <2477952+applejag@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:21:59 +0100 Subject: [PATCH] Replace earthly with dockerfile (#28) --- .dockerignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ Earthfile | 40 ---------------------------------------- README.md | 15 +++++++-------- 4 files changed, 32 insertions(+), 48 deletions(-) create mode 100644 Dockerfile delete mode 100644 Earthfile diff --git a/.dockerignore b/.dockerignore index b97bcc2..d802769 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,7 @@ build # Files not needed during builds .dockerignore .gitignore +Dockerfile Earthfile **/*.md **/*.license diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b046c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2023 Risk.Ident GmbH +# +# SPDX-License-Identifier: CC0-1.0 + +FROM golang:1.21.5-alpine AS build +WORKDIR /jelease +COPY go.mod go.sum ./ +RUN go mod download + +ARG VERSION=latest +COPY . . +RUN go test -v ./... \ + && go build \ + -ldflags "-X github.com/RiskIdent/jelease/cmd.appVersion=$VERSION" \ + -o build/jelease main.go + +FROM alpine +RUN apk add --no-cache ca-certificates git +COPY --from=build /jelease/build/jelease /usr/local/bin/ +CMD ["jelease", "serve"] +USER 10000 +LABEL org.opencontainers.image.source=https://github.com/RiskIdent/jelease +LABEL org.opencontainers.image.description="Automatically create software update PRs and Jira tickets using newreleases.io webhooks." +LABEL org.opencontainers.image.licenses=GPL-3.0-or-later diff --git a/Earthfile b/Earthfile deleted file mode 100644 index 3e00cdc..0000000 --- a/Earthfile +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Risk.Ident GmbH -# -# SPDX-License-Identifier: CC0-1.0 - -VERSION 0.6 -FROM golang:1.21-bullseye -WORKDIR /jelease - -deps: - COPY go.mod go.sum ./ - RUN go mod download - SAVE ARTIFACT go.mod AS LOCAL go.mod - SAVE ARTIFACT go.sum AS LOCAL go.sum - -build: - ARG VERSION=devel - FROM +deps - COPY . . - RUN go test -v ./... \ - && go build \ - -ldflags "-X github.com/RiskIdent/jelease/cmd.appVersion=$VERSION" \ - -o build/jelease main.go - SAVE ARTIFACT build/jelease /jelease AS LOCAL build/jelease - -docker: - ARG VERSION=latest - ARG REGISTRY=ghcr.io/riskident - FROM ubuntu:22.04 - RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates git \ - && rm -rf /var/lib/apt/lists/* - COPY +build/jelease /usr/local/bin - CMD ["jelease", "serve"] - LABEL org.opencontainers.image.source=https://github.com/RiskIdent/jelease - LABEL org.opencontainers.image.description="Automatically create software update PRs and Jira tickets using newreleases.io webhooks." - LABEL org.opencontainers.image.licenses=GPL-3.0-or-later - IF [ "$VERSION" != "latest" ] - SAVE IMAGE --push $REGISTRY/jelease:latest - END - SAVE IMAGE --push $REGISTRY/jelease:$VERSION diff --git a/README.md b/README.md index 233af05..40edfb5 100644 --- a/README.md +++ b/README.md @@ -132,16 +132,15 @@ config file: ## Building the application and docker image -The application uses [earthly](https://earthly.dev/get-earthly) for building -and pushing a docker image. - -After installing earthly, the image can be built by running - ```bash -earhtly +docker +VERSION=v0.4.1 + +podman build -t ghcr.io/riskident/jelease:${VERSION} --build-arg VERSION=${VERSION} +podman tag ghcr.io/riskident/jelease:{${VERSION},latest} -# if you want to push a new image version -earhtly --push +docker --VERSION=v0.4.1 +podman login ghcr.io +podman push ghcr.io/riskident/jelease:${VERSION} +podman push ghcr.io/riskident/jelease:latest ``` You can also persist build flags in a `.env` file, e.g: