Skip to content

Commit

Permalink
feat: dockerfile + auto-publish docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Aug 28, 2024
1 parent 72aa48a commit a913100
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,46 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ship:
needs: build
runs-on: ubuntu-latest

permissions:
packages: write

env:
REGISTRY: ghcr.io

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
env/nginx/
Dockerfile
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.tag }} Release

- name: Extract build artifacts
run: tar -xzvf ./release-${{ needs.build.outputs.tag }}.tar.gz

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ needs.build.outputs.tag }}

deploy:
needs: build
environment: app.prose.org
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM nginx:1.27-alpine-slim as web

RUN rm -rf /etc/nginx/ /var/www/

COPY ./env/nginx /etc/nginx/
COPY ./dist /var/www/

EXPOSE 8080/tcp
26 changes: 26 additions & 0 deletions env/nginx/mime.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
types {
text/html html;
text/css css;
text/xml xml;
text/plain txt;

application/javascript js;
application/json json;

image/jpeg jpeg jpg;
image/gif gif;
image/png png;
image/svg+xml svg;
image/webp webp;
image/x-icon ico;

audio/webm weba;
audio/ogg oga ogg;
audio/x-m4a m4a;

video/mp4 mp4;
video/webm webm;

font/woff woff;
font/woff2 woff2;
}
17 changes: 17 additions & 0 deletions env/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
worker_processes 1;
error_log /dev/stdout info;

events {}

http {
include mime.types;
charset utf-8;
access_log /dev/stdout;

server {
listen 8080;
server_name localhost;

include site.conf;
}
}
25 changes: 25 additions & 0 deletions env/nginx/site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
root /var/www/;

# Robots
location = /robots.txt {
add_header 'Content-Type' 'text/plain';

return 200 'User-agent: *\nDisallow: /\n';
}

# Pages
location / {
# Enforce URLs to end with a trailing slash
rewrite ^/([^\.]+[^/])$ /$1/ permanent;

error_page 404 =200 /index.html;

try_files $uri $uri/ =404;

expires 1d;
}

# Assets
location ~* ^/(assets|favicons|fonts|images|includes|sounds|videos)/(.+)$ {
expires 1w;
}

0 comments on commit a913100

Please sign in to comment.