feat(database): support postgres
This commit is contained in:
parent
0e42b32a1a
commit
673dad651a
|
@ -16,3 +16,8 @@ drone_runner_capacity: "3"
|
||||||
drone_host_port: "8080"
|
drone_host_port: "8080"
|
||||||
drone_database_driver: "sqlite"
|
drone_database_driver: "sqlite"
|
||||||
drone_sqlite_dir: "/var/lib/drone"
|
drone_sqlite_dir: "/var/lib/drone"
|
||||||
|
drone_postgress_data_dir: "/var/lib/postgresql/data"
|
||||||
|
drone_postgress_password: "drone"
|
||||||
|
drone_postgress_user: "drone"
|
||||||
|
drone_postgress_db: "drone"
|
||||||
|
drone_database_datasource: ""
|
||||||
|
|
27
tasks/drone-database.yml
Normal file
27
tasks/drone-database.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- name: Creates postgres directory
|
||||||
|
file:
|
||||||
|
path: "{{ drone_postgress_data_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
register: drone_postgress_data_dir
|
||||||
|
tags:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
- name: start postgres for drone ci
|
||||||
|
docker_container:
|
||||||
|
name: postgres
|
||||||
|
image: postgres:11
|
||||||
|
state: started
|
||||||
|
restart_policy: always
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- "{{ drone_postgress_data_dir }}:/var/lib/postgresql/data"
|
||||||
|
env:
|
||||||
|
POSTGRES_PASSWORD: "{{ drone_postgress_password }}"
|
||||||
|
POSTGRES_USER: "{{ drone_postgress_user }}"
|
||||||
|
POSTGRES_DB: "{{ drone_postgress_db }}"
|
||||||
|
when: drone_postgress_data_dir is defined and drone_postgress_data_dir.changed
|
||||||
|
tags:
|
||||||
|
- postgres
|
|
@ -17,7 +17,7 @@
|
||||||
tags:
|
tags:
|
||||||
- drone-server
|
- drone-server
|
||||||
|
|
||||||
- name: run drone server
|
- name: run drone server with sqlite database
|
||||||
docker_container:
|
docker_container:
|
||||||
name: drone-server
|
name: drone-server
|
||||||
image: "drone/drone:{{ drone_version }}"
|
image: "drone/drone:{{ drone_version }}"
|
||||||
|
@ -28,7 +28,27 @@
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ drone_sqlite_dir }}:/data"
|
- "{{ drone_sqlite_dir }}:/data"
|
||||||
env_file: /etc/drone/drone-server.env
|
env_file: /etc/drone/drone-server.env
|
||||||
when: (drone_server_config is defined and drone_server_config.changed) or
|
when: ((drone_server_config is defined and drone_server_config.changed) or
|
||||||
(drone_sqlite_folder is defined and drone_sqlite_folder.changed)
|
(drone_sqlite_folder is defined and drone_sqlite_folder.changed)) and
|
||||||
|
drone_database_driver == "sqlite"
|
||||||
|
tags:
|
||||||
|
- drone-server
|
||||||
|
|
||||||
|
- name: run drone server with postgres or mysql database
|
||||||
|
docker_container:
|
||||||
|
name: drone-server
|
||||||
|
image: "drone/drone:{{ drone_version }}"
|
||||||
|
state: started
|
||||||
|
restart_policy: always
|
||||||
|
ports:
|
||||||
|
- "{{ drone_host_port }}:80"
|
||||||
|
links:
|
||||||
|
- "{{ drone_database_driver }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ drone_sqlite_dir }}:/data"
|
||||||
|
env_file: /etc/drone/drone-server.env
|
||||||
|
when: ((drone_server_config is defined and drone_server_config.changed) or
|
||||||
|
(drone_postgress_data_dir is defined and drone_postgress_data_dir.changed)) and
|
||||||
|
drone_database_driver != "sqlite"
|
||||||
tags:
|
tags:
|
||||||
- drone-server
|
- drone-server
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
---
|
---
|
||||||
- include: setup.yml
|
- include: setup.yml
|
||||||
|
- include: drone-database.yml
|
||||||
|
when: drone_server_enable == "true" and drone_database_driver != "sqlite"
|
||||||
- include: drone-server.yml
|
- include: drone-server.yml
|
||||||
when: drone_server_enable == "true"
|
when: drone_server_enable == "true"
|
||||||
- include: drone-agent.yml
|
- include: drone-agent.yml
|
||||||
|
|
|
@ -23,3 +23,9 @@ DRONE_LOGS_PRETTY={{ drone_logs_pretty }}
|
||||||
DRONE_LOGS_COLOR={{ drone_logs_color }}
|
DRONE_LOGS_COLOR={{ drone_logs_color }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
DRONE_LOGS_DEBUG=true
|
DRONE_LOGS_DEBUG=true
|
||||||
|
{% if drone_database_driver is defined and drone_database_driver != "sqlite" %}
|
||||||
|
DRONE_DATABASE_DRIVER={{ drone_database_driver }}
|
||||||
|
{% endif %}
|
||||||
|
{% if drone_database_datasource is defined and drone_database_driver != "sqlite" %}
|
||||||
|
DRONE_DATABASE_DATASOURCE={{ drone_database_datasource }}
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user