Skip to content

Commit

Permalink
Dockerize (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: ashe <[email protected]>
  • Loading branch information
eritbh and ashen-dawn authored Aug 29, 2023
1 parent e0f4f6e commit fae7e30
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 56 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and publish Docker image

on:
push:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
56 changes: 0 additions & 56 deletions .github/workflows/deploy.yml

This file was deleted.

11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16-alpine as builder
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build:prod

FROM nginx:alpine
WORKDIR /static
COPY --from=builder /usr/src/app/dist /static
COPY ./nginx.conf /etc/nginx/nginx.conf
23 changes: 23 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
events {
worker_connections 1024;
}

http {
include mime.types;
sendfile on;

server {
listen 80;
listen [::]:80;

autoindex off;

server_name localhost;
server_tokens off;

root /static;
index index.html;
try_files $uri $uri/ /index.html;
gzip_static on;
}
}

0 comments on commit fae7e30

Please sign in to comment.