使用docker-compose 搭建简易git服务器(gitea+postgresql)

使用docker搭建私有git环境提供给小型团队使用,非常简单的,我这里使用的是docker compose。闲话不多说,下面开始。

我gitea和pgsql的docker-compose.yaml都是分开的,设置了同一网络互通,我喜欢这样的设置。

gitea的docker-compose.yaml文件如下

version: "3.7"

services:
  gitea_web:
    image: gitea/gitea:1.10.0
    container_name: gitea
    ports:
      - "3000:3000"
      - "1022:22"
    volumes:
      - "./data:/data"
    restart: always
    networks:
       - pgsql_net

networks:
  pgsql_net:
     #external: true
     name: pgsql_net

pgsql的docker-compose.yaml文件如下

version: '3.7'

services:
  pgsql:
    image: postgres:11.1-alpine
    container_name: pgsql-db
    environment:
      POSTGRES_DB: 数据库名
      POSTGRES_USER: 用户名
      POSTGRES_PASSWORD: 密码
    volumes:
      - './pg_data:/var/lib/postgresql/data'
    restart: always
    networks:
       - pgsql_net

networks:
  pgsql_net:
     name: pgsql_net

分别docker compose up -d启动就好

nginx配置

server {
    listen 80;
    server_name xxx.test.com;
    index index.html index.php index.htm;

    return      301 https://$server_name$request_uri;      #这是nginx最新支持的写法

    location ~ / {
    root  /home/travel/pki-validation;
    index index.html index.php index.htm;
    }
 }

server {
        listen       443 ssl http2;
        server_name  xxx.test.com;

        charset utf-8;
        #index index.html index.htm;
        ssl_certificate  ./fullchain.cer;
        ssl_certificate_key ./test.com.key;
        ssl_session_timeout 5m;
        #优先采取服务器算法
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

        root         /usr/share/nginx/html;

        location /
        {
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        realurl $request_uri;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        Host $http_host;
                proxy_set_header              Referer $http_referer;
                proxy_redirect off;
                client_max_body_size 15m;
        }
        location ~
         {
                        proxy_set_header        X-Real-IP $remote_addr;
                        proxy_set_header        realurl $request_uri;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header        Host $http_host;
                        proxy_set_header        Referer $http_referer;
                        proxy_redirect off;
                        proxy_pass http://127.0.0.1:2433;#端口
         }

}

暂无评论
发表新评论