Initial commit
This commit is contained in:
commit
2a21752463
3 changed files with 111 additions and 0 deletions
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
*.retry
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
.venv
|
||||||
|
.env
|
||||||
|
env
|
||||||
|
venv
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
.vault
|
||||||
|
.vaults/
|
||||||
|
vault
|
||||||
|
vaults/
|
||||||
|
|
||||||
|
roles/
|
||||||
53
playbook.yml
Normal file
53
playbook.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
- hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- name: create required directories
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: '{{ item }}'
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: sonny
|
||||||
|
group: sonny
|
||||||
|
loop:
|
||||||
|
- '{{ app_dir }}'
|
||||||
|
- '{{ data_dir }}'
|
||||||
|
- '{{ postgres_dir }}'
|
||||||
|
|
||||||
|
- name: copy docker-compose file
|
||||||
|
template:
|
||||||
|
src: 'templates/docker-compose.j2'
|
||||||
|
dest: '{{ app_dir }}/docker-compose.yml'
|
||||||
|
|
||||||
|
- name: stop forgejo
|
||||||
|
command: docker compose --file docker-compose.yml down
|
||||||
|
args:
|
||||||
|
chdir: '{{ app_dir }}'
|
||||||
|
|
||||||
|
- name: pull {{ image_tag }}
|
||||||
|
command: docker compose --file docker-compose.yml pull
|
||||||
|
args:
|
||||||
|
chdir: '{{ app_dir }}'
|
||||||
|
|
||||||
|
- name: start forgejo
|
||||||
|
command: docker compose --file docker-compose.yml up --detach
|
||||||
|
args:
|
||||||
|
chdir: '{{ app_dir }}'
|
||||||
|
|
||||||
|
vars:
|
||||||
|
app_dir: '/srv/docker/forgejo'
|
||||||
|
data_dir: '/home/sonny/vm/forgejo/data'
|
||||||
|
postgres_dir: '/home/sonny/vm/forgejo/postgres'
|
||||||
|
|
||||||
|
image_tag: 'codeberg.org/forgejo/forgejo:9'
|
||||||
|
|
||||||
|
postgres_user: forgejo
|
||||||
|
postgres_name: forgejo
|
||||||
|
postgres_password: !vault |
|
||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
38616139663030376462383464343866313865653837386335646331313265373530653534663866
|
||||||
|
3839613831616630363338366635303836353335353433630a376665366632663435633837376265
|
||||||
|
62636164343965663866663530366561326136383937663439383033653935303238636463656364
|
||||||
|
3439656234643262330a356264336637386465643234323832393233306539336162386239343538
|
||||||
|
61363165363338653932336233346536646134313762396463666438663734643765303230356535
|
||||||
|
63653963383433616563393339613665323335336537323965303630626566363762653830323933
|
||||||
|
313334313532346261326436326563636235
|
||||||
42
templates/docker-compose.j2
Normal file
42
templates/docker-compose.j2
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
networks:
|
||||||
|
forgejo:
|
||||||
|
external: false
|
||||||
|
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
image: '{{ image_tag }}'
|
||||||
|
container_name: forgejo
|
||||||
|
environment:
|
||||||
|
- USER_UID=1000
|
||||||
|
- USER_GID=1000
|
||||||
|
- FORGEJO__database__DB_TYPE=postgres
|
||||||
|
- FORGEJO__database__HOST=db:5432
|
||||||
|
- FORGEJO__database__NAME={{ postgres_name }}
|
||||||
|
- FORGEJO__database__USER={{ postgres_user }}
|
||||||
|
- FORGEJO__database__PASSWD={{ postgres_password }}
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- forgejo
|
||||||
|
volumes:
|
||||||
|
- {{ data_dir }}:/data
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
- '22:22'
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:14
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER={{ postgres_user }}
|
||||||
|
- POSTGRES_PASSWORD={{ postgres_password }}
|
||||||
|
- POSTGRES_DB={{ postgres_name }}
|
||||||
|
networks:
|
||||||
|
- forgejo
|
||||||
|
volumes:
|
||||||
|
- {{ postgres_dir }}:/var/lib/postgresql/data
|
||||||
Reference in a new issue