From 0c319cb2b2bbdd6cb95cd9d711ed39c445a7132c Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Thu, 4 Jun 2026 18:05:09 +0200 Subject: [PATCH] added additional config and docs --- .github/docs/docker/README.md | 67 +++++++++++++++++++++++++++++++++++ .gitignore | 3 +- README.md | 22 +++++++++++- docker-compose.yml | 7 +++- frontend/nginx.conf | 2 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 .github/docs/docker/README.md diff --git a/.github/docs/docker/README.md b/.github/docs/docker/README.md new file mode 100644 index 0000000..cd6800b --- /dev/null +++ b/.github/docs/docker/README.md @@ -0,0 +1,67 @@ +# Docker + +## Prerequisites + +You have created a `docker-compose.override.yml` file in the root directory of this repository. + +## Docker Network + +If you want to run the stack in a docker network, you need to change the `BACKEND_HOST` variable in the root `.env` file to `stockhome-backend`. To add a docker network, create a `docker-compose.override.yml` file in the root directory of this repository with the following content: + +```yaml +services: + database: + networks: + - stockhome-network + + backend: + networks: + - stockhome-network + + frontend: + networks: + - stockhome-network + +networks: + stockhome-network: + driver: bridge +``` + +To start off I recommend to set the `BACKEND_HOST` variable to `localhost` and start the stack without a docker network. After you have started the stack and everything is working, you can add a docker network. + +## Ports + +### Change Exposed Ports + +If you want to change the exposed ports, you can do this in the `docker-compose.yml` file like so: + +```yaml +services: + database: + ports: + - "3306:3306" + + backend: + ports: + - "8004:8004" + + frontend: + ports: + - "80:80" +``` + +### Remove Exposed Ports + +If you want to remove the exposed ports, you can do this in the `docker-compose.override.yml` file like so: + +```yaml +services: + database: + ports: !override [] + + backend: + ports: !override [] + + frontend: + ports: !override [] +``` diff --git a/.gitignore b/.gitignore index c752999..b9eba31 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ ToDo.txt .env .docker/volumes .tanstack/tmp -local/ \ No newline at end of file +local/ +docker-compose.override.yml \ No newline at end of file diff --git a/README.md b/README.md index 0727cd9..a3a6461 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ If you haven't installed git, download the source code from this repository from **OR** +_Recommended because it is easier to update then_ + If you want to be always up to date, you can clone this repository by running: ```shell @@ -61,11 +63,16 @@ In the root directory of this repository create an .env file and enter the follo ```txt MYSQL_ROOT_PASSWORD= AUTH_SIGNATURE= +BACKEND_HOST=localhost ``` Make sure that you have set an secure root password and a secure signature. -> **NOTE:** These two values cannot contain special characters. +> **NOTE:** These three values cannot contain special characters. + +The host can be set to the IP address of your server or to `localhost` if you are running the app on your local machine. + +> **Change Docker Config:** If you want to run the stack for example in a docker network or want to change something at the docker config, visit the [Docker docs](./.github/docs/docker/README.md) for this project. ### 4. Start Stockhome @@ -88,6 +95,19 @@ Password: admin _Keep in mind that you should change the password later in the settings page._ +> **NOTE:** If errors occur get yourself some help in the [error code page](./.github/docs/error/README.md). + +> _I'd be grateful if you could report any bugs as issues here in the repository!_ + +## Update + +To update the stack, navigate into the root directory of this repository and run: + +```shell +docker compose pull +docker compose up -d --build +``` + ## Development ### Prerequisites diff --git a/docker-compose.yml b/docker-compose.yml index 0aa0c0f..b95940b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,8 @@ services: build: context: ./backend dockerfile: Dockerfile + ports: + - "8004:8004" environment: DB_HOST: stockhome-mysql DB_USER: root @@ -35,9 +37,12 @@ services: frontend: container_name: stockhome-frontend + ports: + - "80:80" build: ./frontend environment: - VITE_BACKEND_URL: http://localhost:8004 + HOST: ${BACKEND_HOST} + VITE_BACKEND_URL: /backend depends_on: - backend restart: unless-stopped diff --git a/frontend/nginx.conf b/frontend/nginx.conf index c48a206..9ad6c22 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -14,7 +14,7 @@ server { } location /backend/ { - proxy_pass http://stockhome-backend:8004/; + proxy_pass http://${BACKEND_HOST}:8004/; } location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {