-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |