Skip to content

Commit

Permalink
chore: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Jun 20, 2024
2 parents 326c600 + 8bd0a18 commit 88b44cc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ PRIVATE_JWT_SECRET_KEY=""
PUBLIC_WEBSOCKET_URL=""

# Example of local DB
DATABASE_URL="postgresql://postgres:postgres@localhost:6432/db?schema=public&connect_timeout=300"
DATABASE_URL="postgresql://postgres:postgres@localhost:6432/db?schema=public&connect_timeout=300"

# App version
VERSION=""
67 changes: 24 additions & 43 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
name: Build and Push Docker Image

on:
release:
types:
- created
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
paths:
- "src/**"
pull_request:
branches: [ "main" ]
paths:
- "src/**"
workflow_dispatch:
branches:
- main

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: chat-game/app

jobs:
Expand All @@ -29,46 +23,33 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: build-and-push
- name: Build Docker
uses: docker/build-push-action@v5
with:
context: .
build-args: VERSION=nightly
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_NAME }}:nightly

- name: Build Docker (release)
uses: docker/build-push-action@v5
if: github.event_name == 'release'
with:
context: .
build-args: VERSION=${{ github.event.release.name }}
file: ./Dockerfile
platforms: linux/amd64
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ github.event.release.name }},${{ env.IMAGE_NAME }}:latest
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM node:20-alpine AS builder
ARG NODE=node:20-alpine

################# Web builder ##############

FROM $NODE AS builder
WORKDIR /app
COPY package*.json .
RUN npm ci --legacy-peer-deps
Expand All @@ -7,11 +11,18 @@ RUN npx prisma generate
RUN npm run build
RUN npm prune --omit=dev --legacy-peer-deps

FROM node:20-alpine
################# Web App ##############

FROM $NODE
WORKDIR /app
COPY --from=builder /app/build build/
COPY --from=builder /app/node_modules node_modules/
COPY package.json .
EXPOSE 3000

ARG VERSION=nightly
ENV VERSION=${VERSION}
ENV NODE_ENV=production
CMD [ "node", "build" ]

EXPOSE 3000

CMD [ "node", "build" ]

0 comments on commit 88b44cc

Please sign in to comment.