From e2b6846fc1b7f37542ea83238408e99701d708f6 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 15 Oct 2023 19:31:48 +0200 Subject: [PATCH] Fixed Docker Image and docker compose stack --- .env => .env.example | 1 + .github/workflows/deploy.yml | 2 +- .gitignore | 1 + docker-compose.stack.yml | 40 ++++++++++++++++++------------------ docker-compose.yml | 1 + docker/init.sql | 4 ++++ public/index.html | 5 +++++ src/client.jsx | 3 ++- 8 files changed, 35 insertions(+), 22 deletions(-) rename .env => .env.example (91%) create mode 100644 docker/init.sql diff --git a/.env b/.env.example similarity index 91% rename from .env rename to .env.example index 1095baf..1f79fa2 100644 --- a/.env +++ b/.env.example @@ -3,4 +3,5 @@ PORT=3000 REACT_APP_VERSION=1.0.0 REACT_APP_NAME=$npm_package_name +PUBLIC_URL=/ REACT_APP_BACKEND_URL=https://strapi.app.levell.ch/ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9de6922..9fa7922 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,7 +6,7 @@ on: - master jobs: - push_to_registry: + build-and-push-container: name: Build and Push Thilo Container runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index bf7c088..a3836eb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/docker-compose.stack.yml b/docker-compose.stack.yml index b864912..15dcd25 100644 --- a/docker-compose.stack.yml +++ b/docker-compose.stack.yml @@ -5,15 +5,17 @@ services: image: ghcr.io/scout-ch/thilo/thilo_frontend:latest restart: always environment: - - BACKEND_URL=BACKEND_URL + - BACKEND_URL=http://localhost:3031 ports: - - 3000:3000 + - 3030:3000 backend: image: ghcr.io/scout-ch/thilo-api/thilo_api:latest restart: always networks: - internal + ports: + - 3031:1337 depends_on: - database environment: @@ -27,14 +29,14 @@ services: - DATABASE_NAME=strapi - DATABASE_USER=postgres - DATABASE_PASSWORD=admin - ports: - - 1337:3001 linkshortner: - image: shlinkio/shlink:3.4.0 + image: shlinkio/shlink:3.6.4 restart: always networks: - internal + ports: + - 8080:8080 depends_on: - database environment: @@ -45,28 +47,26 @@ services: - DB_PASSWORD=admin - DEFAULT_DOMAIN=thilo.cloud - IS_HTTPS_ENABLED=true - ports: - - 8080:8080 linkshortner-webgui: - image: shlinkio/shlink-web-client:3.9.1 + image: shlinkio/shlink-web-client:3.10.2 restart: always networks: - internal - depends_on: - - linkshortner ports: - 8081:80 + depends_on: + - linkshortner feedback: - image: getfider/fider:stable + image: getfider/fider:main restart: always networks: - internal - depends_on: - - database ports: - "9000:3000" + depends_on: + - database environment: BASE_URL: http://localhost:9000 @@ -89,10 +89,12 @@ services: EMAIL_SMTP_ENABLE_STARTTLS: 'true' database: - image: postgres:15.1 + image: postgres:16.0 restart: always networks: - internal + ports: + - 5432:5432 environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=admin @@ -100,26 +102,24 @@ services: - PGDATA=/data/postgres volumes: - postgres:/data/postgres - ports: - - 5432:5432 + - ./docker/init.sql:/docker-entrypoint-initdb.d/init.sql pgadmin: - image: dpage/pgadmin4 + image: dpage/pgadmin4:7.7 restart: always networks: - internal + ports: + - 5050:80 environment: PGADMIN_DEFAULT_EMAIL: admin@thilo.ch PGADMIN_DEFAULT_PASSWORD: password volumes: - pgadmin:/var/lib/pgadmin - ports: - - 5050:80 networks: internal: - volumes: postgres: pgadmin: diff --git a/docker-compose.yml b/docker-compose.yml index a5f4d72..90cc41f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,5 +5,6 @@ services: build: . environment: - NODE_OPTIONS=--openssl-legacy-provider + - BACKEND_URL=http://localhost:8080 ports: - 3000:3000 diff --git a/docker/init.sql b/docker/init.sql new file mode 100644 index 0000000..83abc12 --- /dev/null +++ b/docker/init.sql @@ -0,0 +1,4 @@ +-- Create databases +CREATE DATABASE "strapi"; +CREATE DATABASE "fider"; +CREATE DATABASE "shlink"; diff --git a/public/index.html b/public/index.html index 436047a..386cef8 100644 --- a/public/index.html +++ b/public/index.html @@ -21,6 +21,11 @@ Learn how to configure a non-root public URL by running `npm run build`. --> + diff --git a/src/client.jsx b/src/client.jsx index 2b703d0..033a069 100644 --- a/src/client.jsx +++ b/src/client.jsx @@ -1,7 +1,8 @@ import axios from "axios"; export default axios.create({ - baseURL: process.env.REACT_APP_BACKEND_URL || 'https://strapi.app.levell.ch/', + // read baseULR for dev from .env file, for production from window.env (set by webpack) + baseURL: process.env.REACT_APP_BACKEND_URL || window.env.BACKEND_URL || 'https://strapi.app.levell.ch/', headers: { "Content-type": "application/json", },