diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 67c4ffb..48e4ec0 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -3,6 +3,7 @@ name: Image on: push: branches: [ "main" ] + pull_request: env: REGISTRY_USER: ${{ github.actor }} @@ -14,6 +15,15 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: vanilla-os/vib-gh-action@v0.7.0 + with: + recipe: 'recipe.yml' + + - uses: actions/upload-artifact@v4 + with: + name: Containerfile + path: Containerfile + - name: Build image run: docker image build -f Containerfile --tag ghcr.io/vanilla-os/differ:main . diff --git a/Containerfile b/Containerfile deleted file mode 100644 index cd4168e..0000000 --- a/Containerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM docker.io/golang:1.21-alpine -LABEL maintainer="Mateus Melchiades" - -WORKDIR /home/user - -# Install dependencies -RUN apk add --update gcc musl-dev sqlite make - -# Copy project files and build -COPY main.go go.mod go.sum go.work Makefile /home/user/ -COPY core /home/user/core/ -COPY diff /home/user/diff/ -COPY types /home/user/types/ -COPY vendor /home/user/vendor/ -RUN make - -# Cleanup -RUN rm -rf main.go go.mod go.sum go.work Makefile core/ types/ vendor/ - -EXPOSE 8080 - -CMD ["/home/user/differ"] diff --git a/recipe.yml b/recipe.yml new file mode 100644 index 0000000..e6df670 --- /dev/null +++ b/recipe.yml @@ -0,0 +1,47 @@ +name: Differ +id: differ +stages: + - id: build + base: docker.io/golang:1.21-alpine + singlelayer: false + labels: + maintainer: Mateus Melchiades + cmd: ["/home/user/differ"] + expose: + "8080": "" + modules: + - name: init + type: shell + source: + type: git + url: https://github.com/Vanilla-OS/Differ + branch: main + commit: latest + commands: + - mkdir /home/user + - cp /sources/init/main.go /home/user/ + - cp /sources/init/go.mod /home/user/ + - cp /sources/init/go.sum /home/user/ + - cp /sources/init/go.work /home/user/ + - cp /sources/init/Makefile /home/user/ + - mv /sources/init/core /home/user/core/ + - mv /sources/init/diff /home/user/diff/ + - mv /sources/init/types /home/user/types/ + - mv /sources/init/vendor /home/user/vendor/ + - rm -rf /sources/init + + - name: install-deps + type: shell + commands: + - apk add gcc musl-dev sqlite make + + - name: build + type: shell + commands: + - cd /home/user + - make + + - name: cleanup + type: shell + commands: + - rm -rf main.go go.mod go.sum go.work Makefile core/ types/ vendor/