Skip to content

Commit

Permalink
draft!: feat: host outline with Docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasPeters committed Jul 12, 2024
1 parent cc223ab commit c52e90a
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 198 deletions.
1 change: 1 addition & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ stdout_callback = yaml
roles_path = roles/

vars_plugins = ./plugins/vars
error_on_undefined_vars = True
19 changes: 1 addition & 18 deletions ansible/roles/outline/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
---

- name: "restart outline"
# when: "_outline_checkout is changed
# or _outline_service_file is changed
# or _outline_env_file is changed"
ansible.builtin.systemd:
systemd:
name: "outline.service"
state: "restarted"
daemon_reload: true

- name: "install dependencies"
become_user: "outline"
become: true
ansible.builtin.command: "yarn install --frozen-lockfile"
args:
chdir: "/var/www/outline/outline"
listen: "yarn install"

- name: "build outline"
become_user: "outline"
become: true
ansible.builtin.command: "yarn build"
args:
chdir: "/var/www/outline/outline"
listen: "yarn build"
76 changes: 32 additions & 44 deletions ansible/roles/outline/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,64 @@
---
- name: "create outline user"
- name: "Create outline user"
ansible.builtin.user:
name: "outline"
state: "present"
shell: "/bin/false"
system: true
home: "/var/www/outline"
move_home: true
system: true
shell: "/sbin/nologin"
password: "!"

- name: "create outline directory"
- name: "Create outline directory"
ansible.builtin.file:
path: "/var/www/outline/outline"
path: "{{ outline_project_source }}"
state: "directory"
owner: "outline"
group: "outline"

- name: "do database setup"
- name: "Do database setup"
become_user: "postgres"
become: true
block:
- name: "ensure Postgres role exists"
- name: "Ensure Postgres role exists"
community.postgresql.postgresql_user:
name: "outline"
state: "present"

- name: "ensure database exists"
- name: "Ensure database exists"
community.postgresql.postgresql_db:
name: "outline"
owner: "outline"
state: "present"

- name: "ensure config directory exists"
ansible.builtin.file:
path: "/etc/outline"
state: "directory"

- name: "create environment file"
- name: "Create outline 'docker-compose.yml' file"
ansible.builtin.template:
src: "outline.env.j2"
dest: "/etc/outline/outline.env"
owner: "root"
src: "docker-compose.yml.j2"
dest: "{{ outline_project_source }}/docker-compose.yml"
owner: "outline"
group: "outline"
mode: "0600"
notify: "restart outline"

- name: "clone repo and do Yarn stuff"
become_user: "outline"
become: true
ansible.builtin.git:
repo: "https://github.com/svsticky/Sticky-Compendium.git"
dest: "/var/www/outline/outline"
version: "main"
notify:
- "yarn install"
- "yarn build"
- "restart outline"

- name: "install Systemd service"
- name: "Create outline 'docker.env' file"
ansible.builtin.template:
src: "outline.service.j2"
dest: "/etc/systemd/system/outline.service"
owner: "root"
mode: "0644"
notify: "restart outline"
src: "docker.env.j2"
dest: "{{ outline_project_source }}/docker.env"
owner: "outline"
group: "outline"
mode: "0600"

- name: "ensure outline service is started and enabled"
ansible.builtin.systemd:
name: "outline.service"
state: "started"
enabled: true
- name: "Docker compose"
ansible.builtin.include_tasks: "../docker/tasks/compose-up.yml"
vars:
- project_source: "{{ outline_project_source }}"

- name: "install nginx config"
ansible.builtin.template:
- name: "Install nginx config"
template:
src: "outline.conf.j2"
dest: "/etc/nginx/sites-enabled/outline.conf"
notify: "reload nginx"

# TODO test creating and restoring backup
# TODO is het erg dat outline:outline in templates staat?
# TODO AWS_S3 accelration URL?
# TODO FILE_STORAGE niet local maar s3?
# TODO compose-up.yml moet misschien andere naam krijgen?
71 changes: 71 additions & 0 deletions ansible/roles/outline/templates/docker-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
services:

outline:
image: outlinewiki/outline:0.76.1
env_file: ./docker.env
# ports:
# - "4568:3000"
network_mode: host
volumes:
- storage-data:/var/lib/outline/data
# depends_on:
# - postgres
# - redis

# redis:
# image: redis
# env_file: ./docker.env
# ports:
# - "6379:6379"
# volumes:
# - ./redis.conf:/redis.conf
# command: ["redis-server", "/redis.conf"]
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 10s
# timeout: 30s
# retries: 3

# postgres:
# image: postgres
# env_file: ./docker.env
# ports:
# - "5432:5432"
# volumes:
# - database-data:/var/lib/postgresql/data
# healthcheck:
# test: ["CMD", "pg_isready", "-d", "outline", "-U", "user"]
# interval: 30s
# timeout: 20s
# retries: 3
# environment:
# POSTGRES_USER: 'user'
# POSTGRES_PASSWORD: 'pass'
# POSTGRES_DB: 'outline'

# https-portal:
# image: steveltn/https-portal
# env_file: ./docker.env
# ports:
# - '80:80'
# - '443:443'
# links:
# - outline
# restart: always
# volumes:
# - https-portal-data:/var/lib/https-portal
# healthcheck:
# test: ["CMD", "service", "nginx", "status"]
# interval: 30s
# timeout: 20s
# retries: 3
# environment:
# DOMAINS: 'docs.mycompany.com -> http://outline:3000'
# STAGE: 'production'
# WEBSOCKET: 'true'
# CLIENT_MAX_BODY_SIZE: '0'

volumes:
# https-portal-data:
storage-data:
# database-data:
Loading

0 comments on commit c52e90a

Please sign in to comment.