commit 8e2ed8b750a4599a388cea342a881e883e40275a Author: root Date: Tue Feb 24 18:13:11 2026 +0000 feat: 0.0.1 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3080b91 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +POSTGRES_USER= +POSTGRES_PASSWORD= +POSTGRES_DB= +SERVER_NAME= \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3818c6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +data +postgres +.env \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..08e575c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +version: "3" + +services: + gitea: + image: docker.gitea.com/gitea:latest + depends_on: + - db + environment: + - USER_UID=1000 + - USER_GID=1000 + - GITEA__database__HOST=db:5432 + - GITEA__database__NAME=${POSTGRES_DB} + - GITEA__database__USER=${POSTGRES_USER} + - GITEA__database__PASSWD=${POSTGRES_PASSWORD} + volumes: + - ./data:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + # ports: + # - "222:22" + restart: always + + db: + image: postgres:17 + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + volumes: + - ./postgres:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 10s + timeout: 5s + retries: 5 + restart: always + + nginx: + image: nginx:stable-alpine + build: + dockerfile: nginx.Dockerfile + args: + SERVER_NAME: ${SERVER_NAME} + ports: + - "443:443" + - "80:80" + volumes: + - /etc/letsencrypt:/etc/letsencrypt:ro + depends_on: + - gitea + restart: always diff --git a/nginx.Dockerfile b/nginx.Dockerfile new file mode 100644 index 0000000..dce809b --- /dev/null +++ b/nginx.Dockerfile @@ -0,0 +1,10 @@ +FROM nginx:stable-alpine + +ARG SERVER_NAME + +ENV SERVER_NAME=${SERVER_NAME} + +# Prepare nginx config with env variables +COPY nginx.conf /etc/nginx/nginx.conf +RUN envsubst '${SERVER_NAME}' < /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.tmp && \ + mv /etc/nginx/nginx.conf.tmp /etc/nginx/nginx.conf \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..171f02b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,41 @@ +user nginx; +worker_processes auto; + +events { + +} + +http { + resolver 127.0.0.11 ipv6=off valid=30s; + + client_max_body_size 10M; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log warn; + + gzip on; + gzip_comp_level 6; + gzip_vary on; + gzip_min_length 256; + gzip_types text/plain text/css application/json application/javascript application/xml image/svg+xml application/font-woff2; + + + server { + listen 443 ssl; + + server_name ${SERVER_NAME}; + ssl_certificate /etc/letsencrypt/live/${SERVER_NAME}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/${SERVER_NAME}/privkey.pem; + + location / { + set $upstream http://gitea:3000; + proxy_pass $upstream; + + proxy_set_header x-real-ip $remote_addr; + proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; + + proxy_http_version 1.1; + proxy_set_header Connection 'upgrade'; + } + } +} \ No newline at end of file