Skip to content

Commit

Permalink
feat: nginx, husky, deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
verekia committed Dec 1, 2024
1 parent 31da969 commit e433ec4
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run pre-push
sh deploy.sh
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:22.11.0-alpine3.20
# Build stage

FROM node:22.11.0-alpine3.20 AS builder

WORKDIR /app

Expand All @@ -20,4 +22,12 @@ COPY . .

RUN npm run build && npm run build-examples && npm run build-website

CMD ["npm", "run", "website"]
# Production stage

FROM nginx:1.26.2-alpine3.20-slim

COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /app/website/dist /usr/share/nginx/html

EXPOSE 80
Binary file added bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker buildx build --platform linux/arm64 --load -t verekia/manapotion .
docker save -o /tmp/manapotion.tar verekia/manapotion
scp /tmp/manapotion.tar midgar:/tmp/
ssh midgar docker load --input /tmp/manapotion.tar
ssh midgar docker compose up -d manapotion
56 changes: 56 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# v2

server {
root /usr/share/nginx/html;
index index.html;

# Preserves port in redirects
absolute_redirect off;

# Gzip
gzip on;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
gzip_min_length 1000;
gzip_comp_level 6;

# Security headers
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";

# Remove trailing slashes
rewrite ^/(.*)/$ /$1 permanent;

# Redirect /index and /index.html to /
rewrite ^/index\.html$ / permanent;
rewrite ^/index$ / permanent;

# Redirect index.html to the path itself
rewrite ^/(.*)/index\.html$ /$1 permanent;

# Remove .html extension - except 404.html
rewrite ^/(?!404)(.+)\.html$ /$1 permanent;

location /.well-known/acme-challenge/ {
set $traefik_host traefik;
if ($hostname ~ "localhost") {
set $traefik_host 127.0.0.1:8080; # Fallback for local development
}
proxy_pass http://$traefik_host;
proxy_set_header Host $host;
}

location / {
try_files $uri $uri.html $uri/index.html =404;
}

error_page 404 /404.html;

location = /404.html {
internal;
}

location = /404 {
internal;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@commitlint/config-conventional": "19.2.2",
"commitlint": "19.2.2",
"husky": "9.0.11",
"husky": "9.1.7",
"lerna": "8.1.2",
"npm-run-all": "4.1.5",
"syncpack": "12.3.0"
Expand Down

0 comments on commit e433ec4

Please sign in to comment.