Skip to content

Commit

Permalink
docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherJMiller committed Dec 16, 2023
1 parent 1f07403 commit 8949b32
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker-publish.yml
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 }}
19 changes: 19 additions & 0 deletions api/Dockerfile
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" ]
16 changes: 16 additions & 0 deletions frontend/Dockerfile
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
26 changes: 26 additions & 0 deletions frontend/nginx.conf
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;
}
}
}

0 comments on commit 8949b32

Please sign in to comment.