Skip to content

Commit 2e93543

Browse files
author
silky
committed
feat: 部署开发,生产环境准备
1 parent 2852708 commit 2e93543

File tree

12 files changed

+480
-0
lines changed

12 files changed

+480
-0
lines changed

docker-compose-infra.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
version: '3.8'
2+
3+
services:
4+
nginx:
5+
image: nginx:latest
6+
container_name: nginx
7+
restart: on-failure
8+
volumes:
9+
- $PWD/docker_compose_conf/nginx/nginx.conf:/etc/nginx/nginx.conf
10+
- $PWD/docker_compose_conf/nginx/conf.d:/etc/nginx/conf.d
11+
- nginx_log:/var/log/nginx # 无关的卷均随机绑定
12+
ports:
13+
- "80:80"
14+
networks:
15+
- gitea_network
16+
nexus:
17+
image: sonatype/nexus3:latest
18+
container_name: nexus3
19+
restart: on-failure
20+
ports:
21+
# web服务使用
22+
- "8081:8081"
23+
# http仓库使用
24+
- "8082:8082"
25+
# https仓库使用,本例不使用
26+
#- "5000:5000"
27+
volumes:
28+
- nexus_data:/nexus-data
29+
environment:
30+
# 配置nexus3服务的内存,避免小规格机器崩掉
31+
INSTALL4J_ADD_VM_PARAMS: "-Xms512m -Xmx512m -XX:MaxDirectMemorySize=512m -Djava.util.prefs.userRoot=/nexus-data/javaprefs"
32+
networks:
33+
- gitea_network
34+
portainer:
35+
image: portainer/portainer:latest
36+
container_name: gitea_portainer
37+
restart: always
38+
ports:
39+
- "9000:9000"
40+
- "8000:8000"
41+
volumes:
42+
- /var/run/docker.sock:/var/run/docker.sock
43+
- portainer_data:/data
44+
environment:
45+
- ADMIN_PASSWORD=admin123456789 # 设置管理员密码
46+
networks:
47+
- gitea_network
48+
gitea:
49+
image: docker.io/gitea/gitea:1.23.1
50+
container_name: gitea
51+
environment:
52+
- USER_UID=1000
53+
- USER_GID=1000
54+
- GITEA__database__DB_TYPE=mysql
55+
- GITEA__database__HOST=mysql:3306
56+
- GITEA__database__NAME=gitea
57+
- GITEA__database__USER=root
58+
- GITEA__database__PASSWD=${MYSQL_ROOT_PASSWORD}
59+
restart: always
60+
networks:
61+
- gitea_network
62+
volumes:
63+
- gitea_data:/data
64+
- $PWD/docker_compose_conf/gitea/app.ini:/data/gitea/conf/app.ini
65+
- /etc/timezone:/etc/timezone:ro
66+
- /etc/localtime:/etc/localtime:ro
67+
ports:
68+
- "3000:3000"
69+
- "222:22"
70+
mysql:
71+
image: mysql:8.0.20
72+
container_name: gitea_mysql
73+
restart: always
74+
privileged: true # 允许root远程连接
75+
ports:
76+
- "3306:3306"
77+
volumes:
78+
- mysql_log:/var/log/mysql
79+
- $PWD/docker_compose_conf/mysql/conf.d:/etc/mysql/conf.d
80+
- mysql_data:/var/lib/mysql
81+
environment:
82+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
83+
MYSQL_DATABASE: gitea
84+
networks:
85+
- gitea_network
86+
# 定义自定义网络
87+
networks:
88+
gitea_network:
89+
name: gitea
90+
driver: bridge
91+
92+
volumes:
93+
nginx_log:
94+
nexus_data:
95+
portainer_data:
96+
mysql_log:
97+
mysql_data:
98+
gitea_data:
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Example configuration file, it's safe to copy this as the default config file without any modification.
2+
3+
# You don't have to copy this file to your instance,
4+
# just run `./act_runner generate-config > config.yaml` to generate a config file.
5+
6+
log:
7+
# The level of logging, can be trace, debug, info, warn, error, fatal
8+
level: info
9+
10+
runner:
11+
# Where to store the registration result.
12+
file: .runner
13+
# Execute how many tasks concurrently at the same time.
14+
capacity: 1
15+
# Extra environment variables to run jobs.
16+
envs:
17+
A_TEST_ENV_NAME_1: a_test_env_value_1
18+
A_TEST_ENV_NAME_2: a_test_env_value_2
19+
# Extra environment variables to run jobs from a file.
20+
# It will be ignored if it's empty or the file doesn't exist.
21+
env_file: .env
22+
# The timeout for a job to be finished.
23+
# Please note that the Gitea instance also has a timeout (3h by default) for the job.
24+
# So the job could be stopped by the Gitea instance if it's timeout is shorter than this.
25+
timeout: 3h
26+
# The timeout for the runner to wait for running jobs to finish when shutting down.
27+
# Any running jobs that haven't finished after this timeout will be cancelled.
28+
shutdown_timeout: 0s
29+
# Whether skip verifying the TLS certificate of the Gitea instance.
30+
insecure: true
31+
# The timeout for fetching the job from the Gitea instance.
32+
fetch_timeout: 5s
33+
# The interval for fetching the job from the Gitea instance.
34+
fetch_interval: 2s
35+
# The labels of a runner are used to determine which jobs the runner can run, and how to run them.
36+
# Like: "macos-arm64:host" or "ubuntu-latest:docker://gitea/runner-images:ubuntu-latest"
37+
# Find more images provided by Gitea at https://gitea.com/gitea/runner-images .
38+
# If it's empty when registering, it will ask for inputting labels.
39+
# If it's empty when execute `daemon`, will use labels in `.runner` file.
40+
labels:
41+
- "ubuntu-latest:docker://gitea/runner-images:ubuntu-latest"
42+
- "ubuntu-22.04:docker://gitea/runner-images:ubuntu-22.04"
43+
- "ubuntu-20.04:docker://gitea/runner-images:ubuntu-20.04"
44+
45+
cache:
46+
# Enable cache server to use actions/cache.
47+
enabled: true
48+
# The directory to store the cache data.
49+
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
50+
dir: ""
51+
# The host of the cache server.
52+
# It's not for the address to listen, but the address to connect from job containers.
53+
# So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
54+
host: ""
55+
# The port of the cache server.
56+
# 0 means to use a random available port.
57+
port: 0
58+
# The external cache server URL. Valid only when enable is true.
59+
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
60+
# The URL should generally end with "/".
61+
external_server: ""
62+
63+
container:
64+
# Specifies the network to which the container will connect.
65+
# Could be host, bridge or the name of a custom network.
66+
# If it's empty, act_runner will create a network automatically.
67+
network: ""
68+
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
69+
privileged: false
70+
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
71+
options:
72+
# The parent directory of a job's working directory.
73+
# NOTE: There is no need to add the first '/' of the path as act_runner will add it automatically.
74+
# If the path starts with '/', the '/' will be trimmed.
75+
# For example, if the parent directory is /path/to/my/dir, workdir_parent should be path/to/my/dir
76+
# If it's empty, /workspace will be used.
77+
workdir_parent:
78+
# Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob
79+
# You can specify multiple volumes. If the sequence is empty, no volumes can be mounted.
80+
# For example, if you only allow containers to mount the `data` volume and all the json files in `/src`, you should change the config to:
81+
# valid_volumes:
82+
# - data
83+
# - /src/*.json
84+
# If you want to allow any volume, please use the following configuration:
85+
# valid_volumes:
86+
# - '**'
87+
valid_volumes: []
88+
# overrides the docker client host with the specified one.
89+
# If it's empty, act_runner will find an available docker host automatically.
90+
# If it's "-", act_runner will find an available docker host automatically, but the docker host won't be mounted to the job containers and service containers.
91+
# If it's not empty or "-", the specified docker host will be used. An error will be returned if it doesn't work.
92+
docker_host: ""
93+
# Pull docker image(s) even if already present
94+
force_pull: true
95+
# Rebuild docker image(s) even if already present
96+
force_rebuild: false
97+
98+
host:
99+
# The parent directory of a job's working directory.
100+
# If it's empty, $HOME/.cache/act/ will be used.
101+
workdir_parent:

docker_compose_conf/gitea/app.ini

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
APP_NAME = Gitea: Git with a cup of tea
2+
RUN_MODE = prod
3+
RUN_USER = git
4+
WORK_PATH = /data/gitea
5+
6+
[repository]
7+
ROOT = /data/git/repositories
8+
9+
[repository.local]
10+
LOCAL_COPY_PATH = /data/gitea/tmp/local-repo
11+
12+
[repository.upload]
13+
TEMP_PATH = /data/gitea/uploads
14+
15+
[server]
16+
APP_DATA_PATH = /data/gitea
17+
DOMAIN = silky.com
18+
SSH_DOMAIN = silky.com
19+
HTTP_PORT = 3000
20+
ROOT_URL = http://silky.com/
21+
DISABLE_SSH = false
22+
SSH_PORT = 22
23+
SSH_LISTEN_PORT = 22
24+
LFS_START_SERVER = true
25+
LFS_JWT_SECRET = RWR3YAnnMrQYgnYH1Txq0DbqN51CFXKmA_DSkDE0vAI
26+
OFFLINE_MODE = true
27+
28+
[database]
29+
PATH = /data/gitea/gitea.db
30+
DB_TYPE = mysql
31+
HOST = mysql:3306
32+
NAME = gitea
33+
USER = root
34+
PASSWD = silky
35+
LOG_SQL = false
36+
SCHEMA =
37+
SSL_MODE = disable
38+
39+
[indexer]
40+
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
41+
42+
[session]
43+
PROVIDER_CONFIG = /data/gitea/sessions
44+
PROVIDER = file
45+
46+
[picture]
47+
AVATAR_UPLOAD_PATH = /data/gitea/avatars
48+
REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars
49+
50+
[attachment]
51+
PATH = /data/gitea/attachments
52+
53+
[log]
54+
MODE = console
55+
LEVEL = info
56+
ROOT_PATH = /data/gitea/log
57+
58+
[security]
59+
INSTALL_LOCK = true
60+
SECRET_KEY =
61+
REVERSE_PROXY_LIMIT = 1
62+
REVERSE_PROXY_TRUSTED_PROXIES = *
63+
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3MzgyMTA3OTd9.hAEOcjnj5P4mj06GeNxQYupI7Vbcqm_zNseC5Syj9ug
64+
PASSWORD_HASH_ALGO = pbkdf2
65+
66+
[service]
67+
DISABLE_REGISTRATION = false
68+
REQUIRE_SIGNIN_VIEW = false
69+
REGISTER_EMAIL_CONFIRM = false
70+
ENABLE_NOTIFY_MAIL = false
71+
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
72+
ENABLE_CAPTCHA = false
73+
DEFAULT_KEEP_EMAIL_PRIVATE = false
74+
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
75+
DEFAULT_ENABLE_TIMETRACKING = true
76+
NO_REPLY_ADDRESS = noreply.localhost
77+
78+
[lfs]
79+
PATH = /data/git/lfs
80+
81+
[mailer]
82+
ENABLED = false
83+
84+
[openid]
85+
ENABLE_OPENID_SIGNIN = true
86+
ENABLE_OPENID_SIGNUP = true
87+
88+
[cron.update_checker]
89+
ENABLED = false
90+
91+
[repository.pull-request]
92+
DEFAULT_MERGE_STYLE = merge
93+
94+
[repository.signing]
95+
DEFAULT_TRUST_MODEL = committer
96+
97+
[oauth2]
98+
JWT_SECRET = 5DNV8lSMMqr9Ve05Mzk960yrydAwRJCPkuX3-TK23oo
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[client]
2+
default-character-set=utf8mb4
3+
4+
[mysql]
5+
default-character-set=utf8mb4
6+
7+
[mysqld]
8+
#服务端口号 默认3306
9+
port=3306
10+
11+
datadir = /work/docker/mysql/data
12+
13+
init_connect='SET NAMES utf8mb4'
14+
character-set-server=utf8mb4
15+
collation-server=utf8mb4_unicode_ci
16+
17+
# 最大连接数
18+
max_connections=200
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name localhost;
5+
6+
#access_log /var/log/nginx/host.access.log main;
7+
8+
location / {
9+
root /usr/share/nginx/html;
10+
index index.html index.htm;
11+
}
12+
13+
#error_page 404 /404.html;
14+
15+
# redirect server error pages to the static page /50x.html
16+
#
17+
error_page 500 502 503 504 /50x.html;
18+
location = /50x.html {
19+
root /usr/share/nginx/html;
20+
}
21+
22+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
23+
#
24+
#location ~ \.php$ {
25+
# proxy_pass http://127.0.0.1;
26+
#}
27+
28+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
29+
#
30+
#location ~ \.php$ {
31+
# root html;
32+
# fastcgi_pass 127.0.0.1:9000;
33+
# fastcgi_index index.php;
34+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
35+
# include fastcgi_params;
36+
#}
37+
38+
# deny access to .htaccess files, if Apache's document root
39+
# concurs with nginx's one
40+
#
41+
#location ~ /\.ht {
42+
# deny all;
43+
#}
44+
}
45+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 80; # 监听 HTTP 端口
3+
server_name nexus.silky.com; # 绑定域名
4+
5+
location / {
6+
proxy_pass http://nexus3:8081;
7+
proxy_set_header Host $host;
8+
proxy_set_header X-Real-IP $remote_addr;
9+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 80; # 监听 HTTP 端口
3+
server_name portainer.silky.com; # 绑定域名
4+
5+
location / {
6+
proxy_pass http://portainer:9000;
7+
proxy_set_header Host $host;
8+
proxy_set_header X-Real-IP $remote_addr;
9+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
10+
}
11+
}

0 commit comments

Comments
 (0)