Skip to content

Commit

Permalink
chore/hetzner-migration/draft/0 (#2291)
Browse files Browse the repository at this point in the history
* chore(svelte): update config

[1] ────
Format apply for latest to 'svelte.config.js'.

* feat(docker): upgrade

[1] ────
Simplify use of 'docker-componse' file to single 'docker-compose', dropping use of based on environment.
[2] ────
Add 'nginx' service for as a reverse proxy.
[3] ────
Update '.dockerignore' file.
[4] ────
Clean up Dockerfile and merged from 'dev.[..]' and 'prod.[..]' files.

* chore(git): update .gitignore

[1] ────
Update '.gitignore' for latest projct structure going forward.

* chore(ts): update/add config

[1] ────
Add new 'tsconfig.server.json' config for 'server/' directory compiling.
[2] ────
Update existing 'tsconfig.json' for latest format and expected structure.

* feat(nginx): initialize

[1] ────
Add initial 'nginx.conf' file configuration.

* feat(server): upgrade

[1] ────
Rename and upgrade 'server.docker.ts' for standard 'dual.instance.ts' module for docker deployment.
[2] ────
Delete 'server.heroku.ts' for the moment, might be re-added for posterity.

* refactor(vite): format config

[1] ────
Apply file comment standard format to 'vite.config.ts'.

* feat(make): update targets

[1] ────
Update 'Makefile' for expected docker targets for 'production' and 'nginx'.

* build(package): new dependency

[1] ────
Add '@types/express' dependency.

* build(package): update scripts

[1] ────
Update deployment scripts.

* refactor(package): displace dependency

[1] ────
Add 'cross-env' dependency to 'production' dependencies.

* feat(docker): update

[1] ────
Update expose port for 'web-prod'

* feat(docker,nginx): upgrade

[1] ────
Update 'docker-compose.yaml' for replica use of the 'web-prod' service.
[2] ────
Update 'nginx.conf' for upstream support for 'replica' handling.

* chore(docker,nginx): displace configuration path

[1] ────
Move path for 'nginx.conf' to '.docker/nginx/*' for better structure.

* chore(docker,nginx): add goaccess support

[1] ────
Update 'nginx.conf' for GoAccess service support.
[2] ────
Update 'docker-compose.yml' for 'GoAccess' support

* chore(docker,goaccess): add goaccess support

[1] ────
Initialize 'goaccess.conf' for GoAccess service configuration.
[2] ────
Update 'docker-compose.yml' for 'GoAccess' support.

* chore(docker,scores): update scores config

[1] ────
Update 'web-prod' service for 'scores' docker configuration. Increased logging limits and set up a target network for 'scores' and 'nginx'.

* chore(git): update gitignore

[1] ────
Update '.gitignore' for latest project sturcture.

* chore(nginx): local config file

[1] ────
Add a 'nginx.dev.conf' file for local development use.

* build(make): update

[1] ────
Update 'Makefile' for 'nginx' target spin up (+ goaccess).

* build(docker,make): update

[1] ────
Update 'Makefile' for 'docker' target complete log export into a target directory, for easier exporting.

* chore(git): update gitignore

[1] ────
Update '.gitignore' for latest project sturcture.

* ci(github): update actions

[1] ────
Delete 'pr-dev-check.yml' as redundant workflow.
[2] ────
Update 'pr-main-check.yml' for ability to not bump version and cause subsequent deployment.
[3] ────
Update 'pr-main-tag.yml' for removal of '(job) dev-branch-reset' and update '(job) deploy' workflow.

* ci(github): update actions

[1] ────
Update 'pr-main-check.yml' for 'pull-request' formatting.
  • Loading branch information
migbash authored Nov 21, 2024
1 parent 9c7a1eb commit f86d192
Show file tree
Hide file tree
Showing 24 changed files with 1,602 additions and 575 deletions.
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

0 comments on commit f86d192

Please sign in to comment.