New:
Snibox
This commit is contained in:
parent
5c22100376
commit
5922227712
18
snibox/files/.env
Normal file
18
snibox/files/.env
Normal file
@ -0,0 +1,18 @@
|
||||
# Secrets
|
||||
SECRET_KEY_BASE=df646c2613b559ae1785672bac90737be0980f7b76c04943550e70b750d8d2d2
|
||||
# SSL
|
||||
FORCE_SSL=false
|
||||
# Database
|
||||
DB_NAME=snibox
|
||||
DB_USER=postgres
|
||||
DB_PASS=123456
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
# Mailgun. Required by 'Reset password feature'. Feel free to start without this setup.
|
||||
MAILGUN_SMTP_PORT=587
|
||||
MAILGUN_SMTP_SERVER=smtp.mailgun.org
|
||||
MAILGUN_SMTP_LOGIN=
|
||||
MAILGUN_SMTP_PASSWORD=
|
||||
MAILGUN_API_KEY=
|
||||
MAILGUN_DOMAIN=
|
||||
MAILGUN_PUBLIC_KEY=
|
27
snibox/files/nginx.conf.j2
Normal file
27
snibox/files/nginx.conf.j2
Normal file
@ -0,0 +1,27 @@
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
server_name {{ http_host }};
|
||||
|
||||
# Allow large attachments
|
||||
client_max_body_size 128M;
|
||||
|
||||
location @proxy-backend {
|
||||
proxy_pass http://proxy_backend;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_redirect off;
|
||||
}
|
||||
location / {
|
||||
root /var/lib/{{ host_directory }}/frontend;
|
||||
index index.html index.htm;
|
||||
try_files $uri/index.html $uri @proxy-backend;
|
||||
}
|
||||
}
|
||||
|
||||
upstream proxy_backend {
|
||||
server localhost:3003;
|
||||
}
|
64
snibox/playbook.yml
Executable file
64
snibox/playbook.yml
Executable file
@ -0,0 +1,64 @@
|
||||
#################################################
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
tasks:
|
||||
- name: Pull Backend image
|
||||
docker_image:
|
||||
name: "{{ backend_image }}"
|
||||
source: pull
|
||||
state: present
|
||||
# force_source: yes
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/.env"
|
||||
dest: "/var/lib/{{ host_directory }}/.env"
|
||||
|
||||
- name: Create Backend container
|
||||
docker_container:
|
||||
name: "{{ backend_container }}"
|
||||
image: "{{ backend_image }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
command: sh -c "cp -r /app/public/ / && rm -rf tmp/pids && ./bin/rails s -p 3003 -b '0.0.0.0'"
|
||||
env_file: "/var/lib/{{ host_directory }}/.env"
|
||||
published_ports:
|
||||
- "127.0.0.1:3003:3003"
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/frontend:/public"
|
||||
links:
|
||||
- "postgres:db"
|
||||
|
||||
- name: Check if Nginx conf file exists
|
||||
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
|
||||
register: status
|
||||
|
||||
- name: No need to reload Nginx
|
||||
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
|
||||
|
||||
- name: Set Nginx conf file
|
||||
when: status.stat.exists == false
|
||||
template:
|
||||
src: "files/nginx.conf.j2"
|
||||
dest: "/etc/nginx/sites-available/{{ http_conf }}"
|
||||
|
||||
- name: Enable new site
|
||||
when: status.stat.exists == false
|
||||
file:
|
||||
src: "/etc/nginx/sites-available/{{ http_conf }}"
|
||||
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
|
||||
state: link
|
||||
notify: Reload Nginx
|
||||
|
||||
handlers:
|
||||
- name: Reload Nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
45
snibox/readme.md
Normal file
45
snibox/readme.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Gitea on Ubuntu
|
||||
|
||||
This playbook will install Gitea on an Ubuntu 19.10 machine.
|
||||
A number of containers will be created with the options specified in the `vars/default.yml` variable file.
|
||||
|
||||
## Settings
|
||||
|
||||
- `create_containers`: number of containers to create.
|
||||
- `default_container_name`: default name for new containers.
|
||||
- `default_container_image`: default image for new containers.
|
||||
- `default_container_command`: default command to run on new containers.
|
||||
|
||||
|
||||
## Running this Playbook
|
||||
|
||||
Quick Steps:
|
||||
|
||||
### 1. Obtain the playbook
|
||||
```shell
|
||||
git clone https://github.com/do-community/ansible-playbooks.git
|
||||
cd ansible-playbooks/docker_ubuntu1804
|
||||
```
|
||||
|
||||
### 2. Customize Options
|
||||
|
||||
```shell
|
||||
nano vars/default.yml
|
||||
```
|
||||
|
||||
```yml
|
||||
#vars/default.yml
|
||||
---
|
||||
create_containers: 4
|
||||
default_container_name: docker
|
||||
default_container_image: ubuntu
|
||||
default_container_command: sleep 1d
|
||||
```
|
||||
|
||||
### 3. Run the Playbook
|
||||
|
||||
```command
|
||||
ansible-playbook -l [target] -i [inventory file] -u [remote user] playbook.yml
|
||||
```
|
||||
|
||||
For more information on how to run this Ansible setup, please check this guide: [How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04).
|
11
snibox/vars/default.yml
Normal file
11
snibox/vars/default.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
http_host: "notes.tanshu.com"
|
||||
http_conf: "notes.tanshu.com.conf"
|
||||
http_url: "https://notes.tanshu.com"
|
||||
|
||||
frontend_container: snibox-fe
|
||||
frontend_image: snibox/nginx-puma:1.15.9
|
||||
backend_container: snibox-be
|
||||
backend_image: snibox/snibox:latest
|
||||
|
||||
host_directory: snibox
|
Loading…
Reference in New Issue
Block a user