From 2485a855157fc9b0f86c25f776b60ac769afd464 Mon Sep 17 00:00:00 2001 From: l <426742@gmail.com> Date: Tue, 25 Jun 2024 11:00:22 +0500 Subject: [PATCH] many changes --- dev.sh | 1 - docker-compose.yml | 81 ----------------------------------------- gitea-cache.yml | 16 -------- gitea.yml | 19 +++++++++- gitlab.yml | 19 ---------- init-db/checkers.sql | 3 -- postgres.yml | 11 +++++- prod.sh | 1 - readme.md | 64 +++++++++++++++++++++++++++++++- secrets/development.env | 25 ------------- start.sh | 29 +++++++++++++++ traefik.yml | 15 ++++++-- www/demo/index.html | 10 ----- 13 files changed, 129 insertions(+), 165 deletions(-) delete mode 100644 dev.sh delete mode 100644 docker-compose.yml delete mode 100644 gitea-cache.yml delete mode 100644 gitlab.yml delete mode 100644 init-db/checkers.sql delete mode 100644 prod.sh delete mode 100644 secrets/development.env create mode 100644 start.sh delete mode 100644 www/demo/index.html diff --git a/dev.sh b/dev.sh deleted file mode 100644 index a940e45..0000000 --- a/dev.sh +++ /dev/null @@ -1 +0,0 @@ -docker compose --env-file .env.dev -f traefik.yml up \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5b3376b..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: "server" - -services: - traefik: - extends: - file: traefik.yml - service: traefik - networks: - - proxynet - - nginx: - extends: - file: nginx.yml - service: nginx - networks: - - proxynet - - nginx-demo: - extends: - file: nginx-demo.yml - service: nginx-demo - networks: - - proxynet - - node-demo: - extends: - file: node-demo.yml - service: node-demo - networks: - - proxynet - #- internal - - postgres: - extends: - file: postgres.yml - service: postgres - networks: - - proxynet - #- internal - - pgadmin: - extends: - file: pgadmin.yml - service: pgadmin - networks: - - proxynet - - gitea: - extends: - file: gitea.yml - service: gitea - networks: - - proxynet - - gitea-cache: - extends: - file: gitea-cache.yml - service: gitea-cache - networks: - - proxynet - - initContainers: - container_name: volume-permissions - image: busybox:1.36.1-glibc - - command: > - sh -c "touch /letsencrypt/acme.json && - chmod -Rv 600 /letsencrypt/* && - chown 65532:65532 /letsencrypt/acme.json && - chmod 755 /init-db/init-database.sh" - #command: ["sh", "-c", "touch /letsencrypt/acme.json && chmod -Rv 600 /letsencrypt/* && chown 65532:65532 /letsencrypt/acme.json && chmod 755 /init-db/init-database.sh"] - volumes: - - ./secrets/letsencrypt:/letsencrypt - - ./init-db:/init-db - -networks: - proxynet: - driver: bridge - external: false - #internal: - diff --git a/gitea-cache.yml b/gitea-cache.yml deleted file mode 100644 index 5056258..0000000 --- a/gitea-cache.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - gitea-cache: - container_name: gitea-cache - image: redis:7.2.5-alpine3.20 - restart: always - networks: - - proxynet - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 15s - timeout: 3s - retries: 30 - logging: - driver: "json-file" - options: - max-size: "1m" \ No newline at end of file diff --git a/gitea.yml b/gitea.yml index 147ae8b..3b981fb 100644 --- a/gitea.yml +++ b/gitea.yml @@ -17,7 +17,6 @@ services: - ROOT_URL=https://gitea.${DOMAIN} - SSH_PORT=222 - SSH_LISTEN_PORT=22 - #- DB_TYPE=sqlite3 - GITEA__cache__ENABLED=true - GITEA__cache__ADAPTER=redis - GITEA__cache__HOST=redis://gitea-cache:6379/0?pool_size=100&idle_timeout=180s @@ -54,4 +53,20 @@ services: - /etc/localtime:/etc/localtime:ro ports: - "3000:3000" - - "222:22" \ No newline at end of file + - "222:22" + + gitea-cache: + container_name: gitea-cache + image: redis:7.2.5-alpine3.20 + restart: always + networks: + - proxynet + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 15s + timeout: 3s + retries: 30 + logging: + driver: "json-file" + options: + max-size: "1m" \ No newline at end of file diff --git a/gitlab.yml b/gitlab.yml deleted file mode 100644 index 6acd17d..0000000 --- a/gitlab.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - gitlab: - image: gitlab/gitlab-ce:17.1.0-ce.0 - container_name: gitlab - restart: always - hostname: 'gitlab.corp.hm' - environment: - GITLAB_OMNIBUS_CONFIG: | - # Add any other gitlab.rb configuration here, each on its own line - external_url 'https://gitlab.corp.hm' - ports: - - '80:80' - - '443:443' - - '22:22' - volumes: - - '$GITLAB_HOME/config:/etc/gitlab' - - '$GITLAB_HOME/logs:/var/log/gitlab' - - '$GITLAB_HOME/data:/var/opt/gitlab' - shm_size: '256m' \ No newline at end of file diff --git a/init-db/checkers.sql b/init-db/checkers.sql deleted file mode 100644 index e55cbd2..0000000 --- a/init-db/checkers.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE DATABASE checkers; -CREATE USER checkers WITH ENCRYPTED PASSWORD '477iyetc44i2th6za8r7'; -GRANT ALL PRIVILEGES ON DATABASE checkers TO checkers; \ No newline at end of file diff --git a/postgres.yml b/postgres.yml index 62280d2..c108fd0 100644 --- a/postgres.yml +++ b/postgres.yml @@ -13,10 +13,17 @@ services: POSTGRES_DB: postgres volumes: - ./data/pgdata:/var/lib/postgresql/data - #- ./init-db:/docker-entrypoint-initdb.d - ./init-db/init-database.sh:/docker-entrypoint-initdb.d/init-database.sh labels: - "traefik.enable=true" - "traefik.tcp.routers.postgresql.rule=HostSNI(`*`)" - "traefik.tcp.services.postgresql.loadbalancer.server.port=5432" - - "traefik.tcp.routers.postgresql.entrypoints=postgres" \ No newline at end of file + - "traefik.tcp.routers.postgresql.entrypoints=postgres" + + initContainers: + container_name: volume-permissions + image: busybox:1.36.1-glibc + command: > + sh -c "chmod 755 /init-db/init-database.sh" + volumes: + - ./init-db:/init-db \ No newline at end of file diff --git a/prod.sh b/prod.sh deleted file mode 100644 index d88373e..0000000 --- a/prod.sh +++ /dev/null @@ -1 +0,0 @@ -docker compose --env-file .env.prod -f docker-compose.yml up \ No newline at end of file diff --git a/readme.md b/readme.md index b3b2a0d..6458fc2 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,63 @@ -Srerver Docker Config \ No newline at end of file +Init: + +sudo git clone git@rozenlab.com:leo/repo-server.git && sudo docker network create proxynet && sudo chmod +x ./repo-server/start.sh + +--------------------------------------------------------------------- + +All run: + +sudo ./start.sh + + +--------------------------------------------------------------------- + +Traefik run: + +Development: +sudo docker compose --env-file .env.dev -f traefik.yml up -d + +Production: +sudo docker compose --env-file .env.prod -f traefik.yml up -d + + +--------------------------------------------------------------------- +Gitea run: + +Development: +sudo docker compose --env-file .env.dev -f gitea.yml up -d + +Production: +sudo docker compose --env-file .env.prod -f gitea.yml up -d + + +--------------------------------------------------------------------- +Postgres run: + +Development: +sudo docker compose -f postgres.yml up -d + +Production: +sudo docker compose -f postgres.yml up -d + + +--------------------------------------------------------------------- +Pgadmin run: + +Development: +sudo docker compose --env-file .env.dev -f pgadmin.yml up -d + +Production: +sudo docker compose --env-file .env.prod -f pgadmin.yml up -d + + +--------------------------------------------------------------------- +Nginx run: + +Development: +sudo docker compose --env-file .env.dev -f nginx.yml up -d + +Production: +sudo docker compose --env-file .env.prod -f nginx.yml up -d + + +--------------------------------------------------------------------- \ No newline at end of file diff --git a/secrets/development.env b/secrets/development.env deleted file mode 100644 index c80aa73..0000000 --- a/secrets/development.env +++ /dev/null @@ -1,25 +0,0 @@ -PORT=5000 -POSTGRES_HOST=postgres -POSTGRES_USER=checkers -POSTGRES_DB=checkers -POSTGRESS_PASSWORD=477iyetc44i2th6za8r7 -POSTGRES_PASSWORD=477iyetc44i2th6za8r7 -POSTGRESS_PORT=5432 -POSTGRES_PORT=5432 -PRIVATE_KEY=secret_key_safasf -JWT_ACCESS_SECRET=7xTJ7WmRGZHGZGRih9w6pLSLvcbz2jpM -JWT_REFRESH_SECRET=ikuwEkxy2xctmSpQLpfw4vdGs6bk9dq3 -SMTP_HOST="smtp.beget.com" -SMTP_PORT=465 -X_SMTP_USER=checkers@rozenlab.com -SMTP_USER=messenger@rozenlab.com -X_SMTP_PASSWORD=X$sory79bak3yen3jzba -SMTP_PASSWORD=M$sory79bak3yen3jzba -API_URL=https://chback.rozenlab.com:7878 -XCLIENT_URL=https://192.168.1.2:9500 -CLIENT_URL=https://localhost -ACCESS_TOKEN_MAX_AGE=70d -REFRESH_TOKEN_MAX_AGE=70d -COOKIE_REFRESH_TOKEN_MAX_AGE=6048000000 -XHTTPS_ENABLE=false -HTTPS_ENABLE=true \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..2ef1674 --- /dev/null +++ b/start.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +if [ -z "$1" ]; then + echo "Please provide the environment type as an argument" + exit 1 +fi + +ENV_TYPE="$1" # dev / prod + +echo "Start server on environment $ENV_TYPE..." + +#Traefik run: +sudo docker compose --env-file .env.$ENV_TYPE -f traefik.yml up -d + +#Gitea run: +sudo docker compose --env-file .env.$ENV_TYPE -f gitea.yml up -d + +#Postgres run: +sudo docker compose -f postgres.yml up -d + +#Pgadmin run: +sudo docker compose --env-file .env.$ENV_TYPE -f pgadmin.yml up -d + +#Nginx run: +sudo docker compose --env-file .env.$ENV_TYPE -f nginx.yml up -d + +echo "All successfully started to environment $ENV_TYPE." \ No newline at end of file diff --git a/traefik.yml b/traefik.yml index 60e47f9..1b64fbd 100644 --- a/traefik.yml +++ b/traefik.yml @@ -8,10 +8,6 @@ services: env_file: - ./secrets/vars.env command: - #tls: - #certificates: - #- certFile: /secrets/selfsigned/selfsigned.crt - #keyFile: /secrets/selfsigned/selfsigned.key - "--providers.file.filename=/traefik/certs.yml" - "--api.insecure=false" - "--api.dashboard=true" @@ -56,6 +52,17 @@ services: options: max-size: "1m" + initContainers: + container_name: volume-permissions + image: busybox:1.36.1-glibc + + command: > + sh -c "touch /letsencrypt/acme.json && + chmod -Rv 600 /letsencrypt/* && + chown 65532:65532 /letsencrypt/acme.json && + volumes: + - ./secrets/letsencrypt:/letsencrypt + networks: proxynet: driver: bridge diff --git a/www/demo/index.html b/www/demo/index.html deleted file mode 100644 index d00a996..0000000 --- a/www/demo/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - -
- -