Skip to content

Commit

Permalink
ci: new matrix build
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Aug 22, 2024
1 parent cc38ce2 commit a662407
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 62 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/build-and-push.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Push Docker

on:
release:
types:
- created
push:
paths-ignore:
- ".md"
branches:
- main

env:
CONTAINER_NAMESPACE: ghcr.io/chat-game

jobs:
build-and-push:
strategy:
fail-fast: false
matrix:
package: [website]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build ${{ matrix.package }}
uses: docker/build-push-action@v6

- name: Build ${{ matrix.package }}
uses: docker/build-push-action@v6
with:
context: .
build-args: VERSION=nightly
file: docker/${{ matrix.package }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CONTAINER_NAMESPACE }}/${{ matrix.package }}:nightly
cache-from: type=registry,ref=${{ env.CONTAINER_NAMESPACE }}/build-cache:${{ matrix.package }}
cache-to: type=registry,mode=max,ref=${{ env.CONTAINER_NAMESPACE }}/build-cache:${{ matrix.package }}

- name: Build ${{ matrix.package }} (release)
uses: docker/build-push-action@v6
if: github.event_name == 'release'
with:
context: .
build-args: VERSION=${{ github.event.release.name }}
file: docker/${{ matrix.package }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CONTAINER_NAMESPACE }}/${{ matrix.package }}:${{ github.event.release.name }},${{ env.CONTAINER_NAMESPACE }}/${{ matrix.package }}:latest
cache-from: type=registry,ref=${{ env.CONTAINER_NAMESPACE }}/build-cache:${{ matrix.package }}
cache-to: type=registry,mode=max,ref=${{ env.CONTAINER_NAMESPACE }}/build-cache:${{ matrix.package }}
13 changes: 6 additions & 7 deletions apps/website/Dockerfile → docker/website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
ARG NODE=node:20.16.0-alpine

################# Web builder ##############
################# Base builder ##############

FROM $NODE AS builder
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn install

COPY . .
RUN yarn install
RUN yarn nx run prisma-schema:generate
RUN yarn nx run website:build

################# Web App ##############
################# Website ##############

FROM $NODE
WORKDIR /app
COPY --from=builder /app/apps/website/.output .output/
COPY --from=builder /app/apps/website/.output .

ARG VERSION=nightly
ENV VERSION=${VERSION}
ENV NODE_ENV=production

EXPOSE 3000

CMD [ "node", ".output/server/index.mjs" ]
CMD ["/app/server/index.mjs"]

0 comments on commit a662407

Please sign in to comment.