diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed754b3..93803ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,10 @@ on: push: branches: - main - pull_request: + paths-ignore: + - '.github/**' + pull_request: + branches: - main jobs: lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 625f35d..537141a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,3 +43,31 @@ jobs: tag_name: ${{ github.event.inputs.version }} generate_release_notes: true files: app + publish: + name: Publish Docker + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + needs: + - release + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/piszmog/my-app + tags: | + type=raw,value=${{ github.event.inputs.version }} + - uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=$${{ github.event.inputs.version }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0736090 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +## Build +FROM golang:1.22-alpine AS build + +ARG VERSION='dev' + +RUN apk update && apk add --no-cache curl + +RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \ + && chmod +x tailwindcss-linux-x64 \ + && mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss + +RUN go install github.com/a-h/templ/cmd/templ@v0.2.648 + +WORKDIR /app + +COPY ./ /app + +RUN templ generate -path ./components \ + && tailwindcss -i ./styles/input.css -o ./dist/assets/css/output@${VERSION}.css --minify + +RUN go build -ldflags="-s -w -X version.Value=${VERSION}" -o my-app + +## Deploy +FROM gcr.io/distroless/static-debian12 + +WORKDIR / + +COPY --from=build /app/my-app /my-app + +EXPOSE 8080 + +CMD ["/my-app"]