40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
---
|
|
- name: show remote host
|
|
debug:
|
|
msg: "the remote server is {{ ansible_host }}"
|
|
- name: create build dir if not exists
|
|
file:
|
|
path: "{{ build_root_abspath }}"
|
|
state: directory
|
|
- name: git clone
|
|
git:
|
|
repo: "https://pvggitea.duckdns.org/GiteaTeam/demo-fastapi.git"
|
|
dest: "{{ build_root_abspath }}"
|
|
remote: "origin"
|
|
version: "main"
|
|
- name: Create Python virtual environment
|
|
command:
|
|
cmd: /usr/bin/python3 -m venv "{{ build_root_abspath }}/venv"
|
|
creates: "{{ build_root_abspath }}/venv"
|
|
- name: install fastapi
|
|
command:
|
|
cmd: source "{{ build_root_abspath }}/venv/bin/activate"
|
|
cmd: pip install "fastapi[all]"
|
|
- name: Check and install Python's SDK
|
|
ansible.builtin.pip:
|
|
name:
|
|
- docker==5.0.3
|
|
- jsondiff==1.3.0
|
|
- pyyaml==6.0
|
|
- docker-compose==1.29.2
|
|
executable: pip3
|
|
when: py3_result.rc == 0
|
|
- name: Build container image
|
|
community.docker.docker_image:
|
|
name: helloworld-fastapi
|
|
source: build
|
|
build:
|
|
path: "{{ build_root_abspath }}"
|
|
pull: false
|
|
tag: "{{ demobackend_version }}"
|