diff --git a/hosting/.env b/hosting/.env new file mode 100644 index 00000000..43a1c75c --- /dev/null +++ b/hosting/.env @@ -0,0 +1,36 @@ +# Image +TAG=dev + +# profile (The value of profile can be dev or not) +PROFILES_ACTIVE= + +# Database +DATABASE_USERNAME=root +DATABASE_PASSWORD=123456 + +# Application url +URL=http://localhost:3000 + +# Application name +NAME=Youdeyiwu + +# Application description +DESCRIPTION=Youdeyiwu is an open-source lightweight forum + +# Interface address +API_SERVER=http://localhost:8080 + +# Is it an HTTPS site +IS_HTTPS_SITE=false + +# Allowed source domain(s) for sending requests, multiple domains separated by commas +SERVER_ACTIONS_ALLOWED_ORIGINS= + +# Set the remotePatterns to allow images, in the format of an array +# IMAGES_REMOTE_PATTERNS_0_PROTOCOL=https +# IMAGES_REMOTE_PATTERNS_0_HOSTNAME=example.com +# IMAGES_REMOTE_PATTERNS_0_PORT= +# IMAGES_REMOTE_PATTERNS_0_PATHNAME=** + +# Other +SHOW_FOOTER=true diff --git a/hosting/README.md b/hosting/README.md index e6a2c637..e5966cc8 100644 --- a/hosting/README.md +++ b/hosting/README.md @@ -1,3 +1,5 @@ # hosting +The docker-compose.yml file in this directory can quickly deploy the frontend and backend of the project, providing a similar experience to a testing environment. +If you need to deploy it in a production environment, you will need to modify the relevant parameters according to the requirements. diff --git a/hosting/docker-compose.yml b/hosting/docker-compose.yml index 991da6b4..e93e3d42 100644 --- a/hosting/docker-compose.yml +++ b/hosting/docker-compose.yml @@ -2,11 +2,21 @@ version: "3" services: youdeyiwu: labels: - - "description=Build Youdeyiwu backend application" + - maintainer=dafengzhen + - description=Run youdeyiwu backend application container_name: youdeyiwu - build: - context: ../ + image: dafengzhen/youdeyiwu + environment: + - TAG + - PROFILES_ACTIVE + - DATABASE_ENDPOINT=youdeyiwu:3306 + - DATABASE_USERNAME + - DATABASE_PASSWORD + depends_on: + - youdeyiwu-db restart: on-failure + volumes: + - logs:/youdeyiwu/logs ports: - "8080:8080" networks: @@ -14,17 +24,53 @@ services: youdeyiwu-web: labels: - - "description=Build Youdeyiwu frontend application" + - maintainer=dafengzhen + - description=Build youdeyiwu frontend application container_name: youdeyiwu-web - build: - context: ../web + image: dafengzhen/youdeyiwu-web + environment: + - TAG + - URL + - NAME + - DESCRIPTION + - API_SERVER=http://youdeyiwu:8080 + - IS_HTTPS_SITE + - SERVER_ACTIONS_ALLOWED_ORIGINS + - SHOW_FOOTER + - IMAGES_REMOTE_PATTERNS_0_PROTOCOL + - IMAGES_REMOTE_PATTERNS_0_HOSTNAME + - IMAGES_REMOTE_PATTERNS_0_PORT + - IMAGES_REMOTE_PATTERNS_0_PATHNAME + depends_on: + - youdeyiwu restart: on-failure ports: - "3000:3000" networks: - youdeyiwu - - youdeyiwu-web + + youdeyiwu-db: + labels: + - maintainer=dafengzhen + - description=Build youdeyiwu database application + container_name: youdeyiwu-db + image: 'mysql:8.2' + restart: on-failure + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=123456 + ports: + - '3306:3306' + networks: + - youdeyiwu networks: youdeyiwu: - youdeyiwu-web: + name: youdeyiwu + +volumes: + logs: + name: youdeyiwu_logs + db: + name: youdeyiwu_db diff --git a/web/docker-compose.yml b/web/docker-compose.yml index ba22aa70..99a394e0 100644 --- a/web/docker-compose.yml +++ b/web/docker-compose.yml @@ -7,6 +7,7 @@ services: container_name: youdeyiwu-web image: "youdeyiwu-web:${TAG}" environment: + - TAG - URL - NAME - DESCRIPTION @@ -14,6 +15,10 @@ services: - IS_HTTPS_SITE - SERVER_ACTIONS_ALLOWED_ORIGINS - SHOW_FOOTER + - IMAGES_REMOTE_PATTERNS_0_PROTOCOL + - IMAGES_REMOTE_PATTERNS_0_HOSTNAME + - IMAGES_REMOTE_PATTERNS_0_PORT + - IMAGES_REMOTE_PATTERNS_0_PATHNAME build: context: . networks: