Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/hetzner-migration/draft/0 #2291

Merged
merged 24 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 📌 High Order Overview │
# ┣──────────────────────────────────────────────────────────────────────────────────┫
# │ ➤ Code Format // V.8.0 │
# │ ➤ Status // 🔒 LOCKED │
# │ ➤ Author(s) // @migbash │
# │ ➤ Maintainer(s) // @migbash │
# │ ➤ Created on // <date-created> │
# ┣──────────────────────────────────────────────────────────────────────────────────┫
# │ 📝 Description │
# ┣──────────────────────────────────────────────────────────────────────────────────┫
# │ Betarena (Module)
# │ |: Instance Variables Definitions
# │ |: 🔗 read-more :: https://pnpm.io/docker
# ╰──────────────────────────────────────────────────────────────────────────────────╯

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🏗️ STEP 0 │ Define Base Step │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

FROM node:18.19.0-alpine as base

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🏗️ STEP 1 │ Initialize Docker Build │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

FROM base AS prod-deps
COPY . /app
WORKDIR /app
RUN apk add --no-cache python3 make g++
RUN \
npm install -g [email protected] && \
npm install --omit=optional --production --ignore-scripts
#

FROM base AS build
COPY . /app
WORKDIR /app
RUN apk add --no-cache python3 make g++
RUN npm install -g [email protected] && npm i --omit=optional
RUN npm run build
RUN npm run "sveltekit|:|build"
RUN npm run "server|:|build"

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🏗️ STEP 2 │ Final Docker Build │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

FROM base AS final
WORKDIR /app
USER node:node
COPY --from=prod-deps /app/node_modules node_modules/
COPY --from=build /app/build build/
COPY --from=build /app/dist/dual.instance.js dual.instance.js
COPY --from=build /app/package.json /app/.env ./

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🏗️ STEP 3 │ Code Deployment │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

EXPOSE 5055
CMD ["npm", "run", "sveltekit|:|start|:|docker"]
29 changes: 0 additions & 29 deletions .docker/dev.Dockerfile

This file was deleted.

37 changes: 0 additions & 37 deletions .docker/dev.docker-compose.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: betarena-scores

services:

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🟩 │ NGINX CONTAINER(s) │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

nginx:
image: nginx:1.27.1
container_name: proxy
ports:
- 80:80
- 443:443
- 8081:8081
# ╭─────
# │ NOTE:
# │ |: Pors for DEVELOPMENT (LOCAL) [commented out]
# ╰─ ⤦⤦⤦⤦
# - 8080:8080
command: ["nginx", "-g", "daemon off;"]
volumes:
# ╭─────
# │ NOTE:
# │ |: Volumes for PRODUCTION
# ╰─ ⤦⤦⤦⤦
- ${HOME}/../etc/letsencrypt:/etc/letsencrypt:ro
- ../.docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ../.docker/goaccess:/etc/nginx/html:ro
- ../.docker/nginx/logs/scores:/var/log/nginx/scores:rw
- ../.docker/nginx/logs/goaccess:/var/log/nginx/goaccess:rw
# ╭─────
# │ NOTE:
# │ |: Volumes for DEVELOPMENT (LOCAL) [commented out]
# ╰─ ⤦⤦⤦⤦
# - ../.docker/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
networks:
- loadbalancer
logging:
driver: local
options:
max-size: 1g
max-file: 5
#

goaccess:
image: allinurl/goaccess:1.9.3
container_name: goaccess
ports:
- 7890:7890
volumes:
- ../.docker/nginx/logs/scores:/var/log/nginx:ro
- ../.docker/goaccess:/srv:rw
command: --config-file=/srv/goaccess.conf --log-file=/var/log/nginx/access.log --log-format=COMBINED --output=/srv/index.html --real-time-html --ping-interval=5
depends_on:
- nginx
#

# ╭──────────────────────────────────────────────────────────────────────────────────╮
# │ 🟦 │ APPLICATION CONTAINER(s) │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

web-prod:
image: betarena-scores:1.0.0
# ╭─────
# │ WARNING:
# │ |: Does not work with 'deploy.replicas: [n]' configuration
# ╰─────
# container_name: web-prod
restart: always
# ╭─────
# │ NOTE:
# │ |: Use the following build configuration for local development
# ╰─────
# build:
# context: ../
# dockerfile: ./.docker/Dockerfile
deploy:
replicas: 3
expose:
- 3000
logging:
driver: local
options:
max-size: 500m
max-file: 5
networks:
- loadbalancer
#

networks:
loadbalancer:
driver: bridge
Loading
Loading