-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1f07403
commit 8949b32
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
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,53 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
service: [api, frontend] | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@40891eba8c2bcd1309b07ba8b11232f313e86779 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.service }} | ||
|
||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@eafaea8d0f5853934deece2ffa67af59d936562b | ||
with: | ||
context: ./${{ matrix.service }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
file: Dockerfile | ||
labels: ${{ steps.meta.outputs.labels }} |
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,19 @@ | ||
FROM node:current as builder | ||
|
||
WORKDIR /build | ||
|
||
# Add Web Files | ||
ADD . . | ||
ADD package.json . | ||
ADD yarn.lock . | ||
|
||
# Build | ||
RUN yarn install && yarn build | ||
|
||
FROM node:current | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /build/dist /app | ||
|
||
CMD [ "node", "main.js" ] |
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,16 @@ | ||
FROM node:current as web_builder | ||
|
||
WORKDIR /build | ||
|
||
# Add Web Files | ||
ADD . . | ||
ADD package.json . | ||
ADD yarn.lock . | ||
|
||
# Build | ||
RUN yarn install && yarn build | ||
|
||
FROM docker.io/nginx:1-alpine | ||
|
||
COPY --from=web_builder /build/dist /usr/share/nginx/html | ||
ADD nginx.conf /etc/nginx/nginx.conf |
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,26 @@ | ||
pid /tmp/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
sendfile on; | ||
|
||
keepalive_timeout 65; | ||
|
||
server { | ||
listen 8080; | ||
server_name localhost; | ||
root /usr/share/nginx/html; | ||
|
||
location /health { | ||
return 200 'alive'; | ||
add_header Content-Type text/plain; | ||
access_log off; | ||
} | ||
} | ||
} |