diff --git a/.github/workflows/pushimage.yaml b/.github/workflows/pushimage.yaml new file mode 100644 index 0000000..4067ee7 --- /dev/null +++ b/.github/workflows/pushimage.yaml @@ -0,0 +1,28 @@ +name: build-push-image + +on: + push: + tags: + - 'v*' + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: https://ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + push: true + tags: ghcr.io/tlinden/kleingebaeck:${{ github.ref_name}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f05943a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.21-alpine as builder + +RUN apk update +RUN apk upgrade +RUN apk add --no-cache git make + +RUN git --version + +WORKDIR /work + +COPY go.mod . +COPY . . +RUN go mod download +RUN make + +FROM alpine:latest +LABEL maintainer="Thomas von Dein " + +#RUN install -o 1001 -g 1001 -d /data + +WORKDIR /app +COPY --from=builder /work/kleingebaeck /app/kleingebaeck + +ENV KLEINGEBAECK_OUTDIR /backup +ENV LANG C.UTF-8 +USER 1001:1001 + +ENTRYPOINT ["/app/kleingebaeck"] +CMD ["-h"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..153b95a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,22 @@ +version: "3.9" +services: + init: + image: alpine:latest + user: "root" + group_add: + - '${GROUP_ID}' + volumes: + - ./test/out:/backup + command: chown -R ${USER_ID}:${USER_ID} /backup + + kleingebaeck: + container_name: kleingebaeck + user: "${USER_ID}:${USER_ID}" + volumes: + - ./test/out:/backup + working_dir: /backup + build: . + image: kleingebaeck:latest + depends_on: + init: + condition: service_completed_successfully