Skip to content

Commit be648c5

Browse files
committed
Define task to load docker containers from archive
1 parent df7feb2 commit be648c5

File tree

10 files changed

+54
-6
lines changed

10 files changed

+54
-6
lines changed

provision-contest/ansible/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ There are a few places where additional files should/can be added:
4444
* Machine/group specific local packages under `roles/base_packages/files/install-*/`.
4545
* Judgehost chroot local packages under `roles/judgedaemon/files/install-chroot/`.
4646
* The vendor dependencies under `roles/domjudge_checkout/files/vendor.tgz`.
47+
* Machine/group specific docker containers under `roles/docker/files/containers-*/`.
4748

4849
## TODO
4950

provision-contest/ansible/group_vars/onprem/secret.yml.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ PRESCLIENT_CONTEST: nwerc18
7070
# Sentry DSN URL
7171
# SENTRY_DSN:
7272

73-
# Glitchtip
73+
# GlitchTip
7474
# GLITCHTIP_SECRET: {some-strong-glitchtip-password}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Loading containers from archives
2+
Any container `.tar` files placed in a `containers-<host_type>` directory will be loaded as a container for the said host type.
3+
The container will be tagged with the relative path starting from `containers-<host_type>`, without the `.tar` file extension.
4+
For example, the file `containers-glitchtip/glitchtip/glitchtip:v4.1.3.tar` will be loaded as a container tagged `glitchtip/glitchtip:v4.1.3` for the `glitchtip` host type.
5+
Note that a nested directory structure is needed to tag containers which have both an organization and a container name.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.tar

provision-contest/ansible/roles/docker/files/containers-glitchtip/glitchtip/.gitignore

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- block:
3+
- name: Check for existing container
4+
community.docker.docker_image_info:
5+
name: "{{ img_name }}"
6+
register: result
7+
8+
- block:
9+
- name: Create temp container directory
10+
file:
11+
path: /tmp/dj_ansible
12+
state: directory
13+
owner: root
14+
group: root
15+
mode: 0700
16+
17+
- name: Transfer container archive
18+
copy:
19+
src: "{{ item.src }}"
20+
dest: "{{ img_path }}"
21+
owner: root
22+
group: root
23+
mode: 0700
24+
25+
- name: Import container from archive
26+
community.docker.docker_image:
27+
name: "{{ img_name }}"
28+
load_path: "{{ img_path }}"
29+
source: load
30+
when: not result.images
31+
vars:
32+
img_name: "{{ item.path | splitext | first }}"
33+
img_path: "/tmp/dj_ansible/{{ item.path | basename }}"

provision-contest/ansible/roles/docker/tasks/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@
2424
- name: Install Docker module for Python
2525
pip:
2626
name: docker
27+
28+
- name: Load container archives
29+
include_tasks: load-container.yml
30+
with_filetree:
31+
- files/containers-{{ host_type }}/
32+
when: item.state == 'file' and (item.path | splitext | last) == ".tar"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
- name: Restart Glitchtip
2+
- name: Restart GlitchTip
33
community.docker.docker_compose_v2:
44
project_src: /opt/glitchtip
5+
files:
6+
- docker-compose.yaml
57
state: restarted

provision-contest/ansible/roles/glitchtip/tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
src: templates/docker-compose.yaml.j2
1111
dest: /opt/glitchtip/docker-compose.yaml
1212

13-
- name: Deploy Glitchtip compose stack
13+
- name: Deploy GlitchTip compose stack
1414
community.docker.docker_compose_v2:
1515
project_src: /opt/glitchtip
1616
files:

provision-contest/ansible/roles/glitchtip/templates/docker-compose.yaml.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ x-environment:
66
SECRET_KEY: {{GLITCHTIP_SECRET}}
77
PORT: {{glitchtip_port}}
88
EMAIL_URL: consolemail://
9-
GLITCHTIP_DOMAIN: http://glitchtip.domjudge
10-
DEFAULT_FROM_EMAIL: email@glitchtip.domjudge
9+
GLITCHTIP_DOMAIN: http://glitchtip:{{glitchtip_port}}
10+
DEFAULT_FROM_EMAIL: email@glitchtip
1111
CELERY_WORKER_AUTOSCALE: "1,1"
1212
CELERY_WORKER_MAX_TASKS_PER_CHILD: "1000"
1313

@@ -31,7 +31,7 @@ services:
3131
image: glitchtip/glitchtip:v4.1.3
3232
depends_on: *default-depends_on
3333
ports:
34-
- {{glitchtip_port}}:8000
34+
- {{glitchtip_port}}:{{glitchtip_port}}
3535
environment: *default-environment
3636
restart: unless-stopped
3737
volumes:

0 commit comments

Comments
 (0)