diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..f160f73 --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,44 @@ +name: Build Container Image +on: [ push ] +jobs: + image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # reference: https://github.com/containers/podman/discussions/17868 + - name: Tar as root + run: | + sudo mv -fv /usr/bin/tar /usr/bin/tar.orig + echo -e '#!/bin/sh\n\nsudo /usr/bin/tar.orig "$@"' | sudo tee -a /usr/bin/tar + sudo chmod +x /usr/bin/tar + - name: Enable caching for podman-machine + - name: Cache Podman + uses: actions/cache@v4 + with: + path: | + ~/.local/share/containers + ~/.config/containers + key: ${{ runner.os }}-${{ hashFiles('**/*.Dockerfile', 'build_image.sh', 'VERSION') }} + - name: Login to Container Registry + uses: redhat-actions/podman-login@v1 + with: + registry: git.0x7f.app + username: ${{ secrets.CONTAINER_USERNAME }} + password: ${{ secrets.CONTAINER_PASSWORD }} + - name: Write Sentry DSN + run: echo -n "$SENTRY_DSN" > dsn.txt + env: + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + - name: Build Base Image + if: startsWith(github.ref, 'refs/tags/') + run: ./build_image.sh base + env: + DOCKER: podman + - name: Build Server Image + run: ./build_image.sh server + env: + DOCKER: podman + - name: Build Runner Image + run: ./build_image.sh runner + env: + DOCKER: podman diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index d4be074..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build Docker Image -on: [ push ] -jobs: - image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Login to Container Registry - uses: docker/login-action@v3 - with: - registry: git.0x7f.app - username: ${{ secrets.CONTAINER_USERNAME }} - password: ${{ secrets.CONTAINER_PASSWORD }} - - name: Write Sentry DSN - run: echo -n "$SENTRY_DSN" > dsn.txt - env: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - - name: Build Base Image - if: startsWith(github.ref, 'refs/tags/') - run: ./build_image.sh base - env: - DOCKER: docker - - name: Build Server Image - run: ./build_image.sh server - env: - DOCKER: docker - - name: Build Runner Image - run: ./build_image.sh runner - env: - DOCKER: docker diff --git a/Runner.Dockerfile b/Runner.Dockerfile index 75d52ea..43bdeee 100644 --- a/Runner.Dockerfile +++ b/Runner.Dockerfile @@ -6,7 +6,7 @@ ENV CGO_ENABLED=0 WORKDIR /builder RUN apk add --no-cache git make -RUN --mount=type=cache,id=golang,target=/go/pkg go install github.com/swaggo/swag/cmd/swag@latest +RUN go install github.com/swaggo/swag/cmd/swag@latest ARG IMAGE_PREFIX=git.0x7f.app/woj ENV CONTAINER_IMAGE_FULL=${IMAGE_PREFIX}/ubuntu-full:latest @@ -14,10 +14,10 @@ ENV CONTAINER_IMAGE_RUN=${IMAGE_PREFIX}/ubuntu-run:latest COPY go.mod /builder/go.mod COPY go.sum /builder/go.sum -RUN --mount=type=cache,id=golang,target=/go/pkg go mod download +RUN go mod download COPY . /builder -RUN --mount=type=cache,id=golang,target=/go/pkg make build +RUN make build # main image diff --git a/Server.Dockerfile b/Server.Dockerfile index 260feec..4884884 100644 --- a/Server.Dockerfile +++ b/Server.Dockerfile @@ -6,14 +6,14 @@ ENV CGO_ENABLED=0 WORKDIR /builder RUN apk add --no-cache git make -RUN --mount=type=cache,id=golang,target=/go/pkg go install github.com/swaggo/swag/cmd/swag@latest +RUN go install github.com/swaggo/swag/cmd/swag@latest COPY go.mod /builder/go.mod COPY go.sum /builder/go.sum -RUN --mount=type=cache,id=golang,target=/go/pkg go mod download +RUN go mod download COPY . /builder -RUN --mount=type=cache,id=golang,target=/go/pkg make build +RUN make build # UI Builder FROM git.0x7f.app/woj/woj-ui:1.1.0 AS ui-builder