hedy: improve self-build
This commit is contained in:
parent
c330d87814
commit
1d479707f1
3 changed files with 49 additions and 27 deletions
|
@ -5,7 +5,13 @@ hedy_user_username: hedy
|
||||||
hedy_user_groupname: hedy
|
hedy_user_groupname: hedy
|
||||||
hedy_base_path: /home/hedy
|
hedy_base_path: /home/hedy
|
||||||
hedy_data_path: /home/hedy/data
|
hedy_data_path: /home/hedy/data
|
||||||
|
|
||||||
|
# Building. Default is to build on the target. To build elsewhere,
|
||||||
|
# change host ('localhost' for Ansible host) and perhaps path.
|
||||||
hedy_docker_src_files_path: /home/hedy/docker-src
|
hedy_docker_src_files_path: /home/hedy/docker-src
|
||||||
|
hedy_builder_host: "{{ ansible_host }}"
|
||||||
|
hedy_builder_username: "{{ hedy_user_username }}"
|
||||||
|
hedy_builder_groupname: "{{ hedy_builder_username }}"
|
||||||
|
|
||||||
hedy_docker_image: hedy:latest
|
hedy_docker_image: hedy:latest
|
||||||
hedy_container_image_self_build: true
|
hedy_container_image_self_build: true
|
||||||
|
|
36
tasks/build-hedy.yml
Normal file
36
tasks/build-hedy.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Hedy build paths
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0700
|
||||||
|
owner: "{{ hedy_builder_username }}"
|
||||||
|
group: "{{ hedy_builder_groupname }}"
|
||||||
|
with_items:
|
||||||
|
- {path: "{{ hedy_docker_src_files_path }}"}
|
||||||
|
|
||||||
|
- name: Hedy build git repository
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: "{{ hedy_container_image_self_build_repo }}"
|
||||||
|
dest: "{{ hedy_docker_src_files_path }}"
|
||||||
|
version: "{{ hedy_container_image_self_build_version }}"
|
||||||
|
force: "yes"
|
||||||
|
register: hedy_git_pull_results
|
||||||
|
|
||||||
|
- name: Hedy build translations
|
||||||
|
command:
|
||||||
|
cmd: "pybabel compile -f -d translations"
|
||||||
|
chdir: "{{ hedy_docker_src_files_path }}"
|
||||||
|
#when: "hedy_git_pull_results.changed"
|
||||||
|
|
||||||
|
- name: Hedy build Docker image
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: "{{ hedy_docker_image }}"
|
||||||
|
source: build
|
||||||
|
force_source: "{{ hedy_git_pull_results.changed }}"
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
path: "{{ hedy_docker_src_files_path }}"
|
||||||
|
pull: true
|
||||||
|
push: true
|
|
@ -15,45 +15,25 @@
|
||||||
with_items:
|
with_items:
|
||||||
- {path: "{{ hedy_base_path }}", when: true}
|
- {path: "{{ hedy_base_path }}", when: true}
|
||||||
- {path: "{{ hedy_data_path }}", when: true}
|
- {path: "{{ hedy_data_path }}", when: true}
|
||||||
- {path: "{{ hedy_docker_src_files_path }}", when: "{{ hedy_container_image_self_build }}"}
|
|
||||||
when: "item.when | bool"
|
when: "item.when | bool"
|
||||||
|
|
||||||
- name: Ensure Hedy repository is present on self-build
|
- delegate_to: "{{ hedy_builder_host }}"
|
||||||
ansible.builtin.git:
|
when: "hedy_container_image_self_build | bool"
|
||||||
repo: "{{ hedy_container_image_self_build_repo }}"
|
|
||||||
dest: "{{ hedy_docker_src_files_path }}"
|
|
||||||
version: "{{ hedy_container_image_self_build_version }}"
|
|
||||||
force: "yes"
|
|
||||||
become: true
|
become: true
|
||||||
become_user: "{{ hedy_user_username }}"
|
become_user: "{{ hedy_builder_username }}"
|
||||||
register: hedy_git_pull_results
|
block:
|
||||||
when: "hedy_container_image_self_build | bool"
|
- include_tasks: "build-hedy.yml"
|
||||||
|
|
||||||
- command:
|
|
||||||
cmd: "pybabel compile -f -d translations"
|
|
||||||
chdir: "{{ hedy_docker_src_files_path }}"
|
|
||||||
#when: "hedy_container_image_self_build | bool and hedy_git_pull_results.changed"
|
|
||||||
|
|
||||||
- name: Ensure Hedy Docker image is built
|
|
||||||
community.docker.docker_image:
|
|
||||||
name: "{{ hedy_docker_image }}"
|
|
||||||
source: build
|
|
||||||
force_source: "{{ hedy_git_pull_results.changed }}"
|
|
||||||
build:
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
path: "{{ hedy_docker_src_files_path }}"
|
|
||||||
pull: true
|
|
||||||
when: "hedy_container_image_self_build | bool"
|
|
||||||
|
|
||||||
- name: Hedy container running
|
- name: Hedy container running
|
||||||
community.docker.docker_container:
|
community.docker.docker_container:
|
||||||
name: "hedy"
|
name: "hedy"
|
||||||
image: "{{ hedy_docker_image }}"
|
image: "{{ hedy_docker_image }}"
|
||||||
|
pull: "{{ hedy_pull and hedy_docker_image.endswith(':latest') }}"
|
||||||
restart_policy: unless-stopped
|
restart_policy: unless-stopped
|
||||||
published_ports:
|
published_ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
#- "{{ hedy_data_path }}:/app"
|
- "{{ hedy_data_path }}/dev_database.json:/app/dev_database.json"
|
||||||
env:
|
env:
|
||||||
BASE_URL: "{{ hedy_base_url }}"
|
BASE_URL: "{{ hedy_base_url }}"
|
||||||
# https://github.com/hedyorg/hedy/wiki/Hedy-Development-Process#environment-variables
|
# https://github.com/hedyorg/hedy/wiki/Hedy-Development-Process#environment-variables
|
||||||
|
|
Loading…
Reference in a new issue