From 0f16571ee36390a71461b34ed6959a3ce69443f1 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 11 Oct 2023 08:36:43 +0200 Subject: [PATCH] chore: add local prod script --- docker-compose.dev.yml | 3 +- docker-compose.prod.yml | 106 ++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- vitest.workspace.ts | 6 ++- 4 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 docker-compose.prod.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index d03dd681..f3fb0d29 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -46,7 +46,7 @@ services: ports: - 6379:6379 volumes: - - ./data/redis:/data + - redisdata:/data healthcheck: test: ['CMD', 'redis-cli', 'ping'] interval: 5s @@ -107,3 +107,4 @@ networks: volumes: pgdata: + redisdata: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..1931a91a --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,106 @@ +version: '3.7' + +services: + tipi-reverse-proxy: + container_name: tipi-reverse-proxy + image: traefik:v2.8 + restart: on-failure + ports: + - 80:80 + - 443:443 + - 8080:8080 + command: --providers.docker + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ${PWD}/traefik:/root/.config + - ${PWD}/traefik/shared:/shared + networks: + - tipi_main_network + + tipi-db: + container_name: tipi-db + image: postgres:14 + restart: unless-stopped + stop_grace_period: 1m + volumes: + - pgdata:/var/lib/postgresql/data + ports: + - 5432:5432 + environment: + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_USER: tipi + POSTGRES_DB: tipi + healthcheck: + test: ['CMD-SHELL', 'pg_isready -d tipi -U tipi'] + interval: 5s + timeout: 10s + retries: 120 + networks: + - tipi_main_network + + tipi-redis: + container_name: tipi-redis + image: redis:7.2.0 + restart: unless-stopped + command: redis-server --requirepass ${REDIS_PASSWORD} + ports: + - 6379:6379 + volumes: + - redisdata:/data + healthcheck: + test: ['CMD', 'redis-cli', 'ping'] + interval: 5s + timeout: 10s + retries: 120 + networks: + - tipi_main_network + + tipi-dashboard: + build: + context: . + dockerfile: Dockerfile + container_name: tipi-dashboard + depends_on: + tipi-db: + condition: service_healthy + tipi-redis: + condition: service_healthy + env_file: + - .env + environment: + NODE_ENV: development + networks: + - tipi_main_network + ports: + - 3000:3000 + volumes: + - ${PWD}/.env:/runtipi/.env + - ${PWD}/state:/runtipi/state + - ${PWD}/repos:/runtipi/repos:ro + - ${PWD}/apps:/runtipi/apps + - ${PWD}/logs:/app/logs + - ${PWD}/traefik:/runtipi/traefik + - ${STORAGE_PATH}:/app/storage + labels: + traefik.enable: true + traefik.http.services.dashboard.loadbalancer.server.port: 3000 + traefik.http.middlewares.redirect-to-https.redirectscheme.scheme: https + # Local domain + traefik.http.routers.dashboard-local-insecure.rule: Host(`${LOCAL_DOMAIN}`) + traefik.http.routers.dashboard-local-insecure.entrypoints: web + traefik.http.routers.dashboard-local-insecure.service: dashboard + traefik.http.routers.dashboard-local-insecure.middlewares: redirect-to-https + # secure + traefik.http.routers.dashboard-local.rule: Host(`${LOCAL_DOMAIN}`) + traefik.http.routers.dashboard-local.entrypoints: websecure + traefik.http.routers.dashboard-local.tls: true + traefik.http.routers.dashboard-local.service: dashboard + +networks: + tipi_main_network: + driver: bridge + name: runtipi_tipi_main_network + +volumes: + pgdata: + redisdata: diff --git a/package.json b/package.json index 1464a8da..a6f562b4 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "start:dev-container": "./.devcontainer/filewatcher.sh && npm run start:dev", "start:rc": "docker compose -f docker-compose.rc.yml --env-file .env up --build", "start:dev": "npm run prepare && docker compose -f docker-compose.dev.yml up --build", - "start:e2e": "./scripts/start-e2e.sh latest", + "start:prod": "npm run prepare && docker compose -f docker-compose.prod.yml up --build", "start:pg": "docker run --name test-db -p 5433:5432 -d --rm -e POSTGRES_PASSWORD=postgres postgres:14", "version": "echo $npm_package_version", "release:rc": "./scripts/deploy/release-rc.sh", diff --git a/vitest.workspace.ts b/vitest.workspace.ts index 33116fa1..64a0168e 100644 --- a/vitest.workspace.ts +++ b/vitest.workspace.ts @@ -1,9 +1,11 @@ -import { defineWorkspace } from 'vitest/config'; +import { defineWorkspace, UserWorkspaceConfig } from 'vitest/config'; import tsconfigPaths from 'vite-tsconfig-paths'; +type Plugin = Exclude[number]; + export default defineWorkspace([ { - plugins: [tsconfigPaths()], + plugins: [tsconfigPaths() as Plugin], test: { globals: true, name: 'server',