-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_create_frontend_image.yaml
61 lines (60 loc) · 2.12 KB
/
3_create_frontend_image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-
hosts: localhost
vars_files:
- external_vars.yaml
vars:
db_user_password: "{{ lookup('password', 'db.user.password') }}"
gcloud_creds_text: "{{ lookup('pipe', 'gcloud config config-helper --format=json') }}"
gcloud_credentials: "{{ gcloud_creds_text | json_query('@') }}"
tags: create
tasks:
-
name: Build the frontend image
become: true
changed_when: true # force re-building the image, 'force_source' isn't enough
docker_image:
name: "frontend:latest"
source: build
#force_source: true
build:
pull: true
rm: true
path: "{{ app_name }}"
args:
DB_SERVER: "mariadb-service"
DB_PASSWORD: "{{ db_user_password }}"
register: frontend_image
-
name: This is the frontend image
debug:
var: frontend_image
-
name: Log previous sessions out of container repo
become: true
docker_login:
registry_url: "https://{{ container_repo_server }}"
state: absent
-
name: Log in to container repo
become: true
docker_login:
registry_url: "https://{{ container_repo_server }}"
username: "_dcgcloud_token"
password: "{{ gcloud_credentials.credential.access_token }}"
-
name: Tag and push the image to the container repo
become: true
docker_image:
name: "frontend"
tag: "latest"
force_tag: true
push: true
repository: "{{ container_repo_server }}/{{ gcp_project_id }}/frontend"
source: local
-
name: Log out of container repo
become: true
docker_login:
registry_url: "https://{{ container_repo_server }}"
state: absent
# vim: set sw=4 ts=4 et indk= :