Skip to content

Commit 9d0de99

Browse files
authored
[LAB-589] Adding receptor dockerfile (#638)
1 parent 40604f8 commit 9d0de99

File tree

7 files changed

+84
-52
lines changed

7 files changed

+84
-52
lines changed

infrastructure/ansible/files/bacalhau.service

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Description=Bacalhau
33

44
[Service]
5+
Restart=on-failure
6+
RestartSec=5s
57
User=ubuntu
68
Group=ubuntu
79
ExecStart=bacalhau serve \

infrastructure/ansible/files/compute.service

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Description=Bacalhau
33

44
[Service]
5+
Restart=on-failure
6+
RestartSec=5s
57
User=ubuntu
68
Group=ubuntu
79
ExecStart=bacalhau serve \

infrastructure/ansible/files/ipfs.service

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Description=IPFS daemon
33

44
[Service]
5+
Restart=on-failure
6+
RestartSec=5s
57
User=ubuntu
68
Group=ubuntu
79
ExecStart=ipfs daemon --routing=dhtclient

infrastructure/ansible/files/receptor.service

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Description=Receptor Web Service
33

44
[Service]
5+
Restart=on-failure
6+
RestartSec=5s
57
User=ubuntu
68
Group=ubuntu
79
WorkingDirectory={{ plex_dir }}/receptor

infrastructure/ansible/files/requester.service

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Description=Bacalhau Requester
33

44
[Service]
5+
Restart=on-failure
6+
RestartSec=5s
57
User=ubuntu
68
Group=ubuntu
79
ExecStart=bacalhau serve \

infrastructure/ansible/tasks/install_bacalhau_tasks.yaml

+52-52
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,6 @@
2020
- name: Only do this if bacalhau isnt installed or upgrade is needed
2121
when: bacalhau_installed_version is undefined or bacalhau_installed_version != bacalhau_version
2222
block:
23-
- name: Fetch AWS EC2 Metadata facts
24-
amazon.aws.ec2_metadata_facts:
25-
26-
- name: Print environment info
27-
ansible.builtin.debug:
28-
msg: "Running on environment: {{ ansible_ec2_tags_instance_Env }}"
29-
when: ansible_ec2_tags_instance_Env is defined
30-
31-
- name: Set fact when its prod node
32-
ansible.builtin.set_fact:
33-
requester_hostname: "requester.labdao.xyz"
34-
ipfs_hostname: "ipfs.labdao.xyz"
35-
when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower == "prod"
36-
37-
- name: Set fact when its non-prod node
38-
ansible.builtin.set_fact:
39-
requester_hostname: "requester.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz"
40-
ipfs_hostname: "ipfs.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz"
41-
when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower != "prod"
42-
43-
# Bacalhau PeerID, example `curl -s bacalhau.staging.labdao.xyz:1234/node_info | jq -r '.PeerInfo.ID'`
44-
- name: Determine requester bacalhau peer id
45-
ansible.builtin.uri:
46-
url: "http://{{ requester_hostname }}:1234/node_info"
47-
return_content: true
48-
register: requester_output
49-
when: requester_hostname is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*")
50-
51-
- name: Set requester_peer url
52-
ansible.builtin.set_fact:
53-
# requester_peer: /dns4/requester.staging.labdao.xyz/tcp/1235/p2p/QmeLa2fx2FMNDWbeY3UqjELc1MbKwNxggcmdBmLZepY6VK
54-
requester_peer: "/dns4/{{ requester_hostname }}/tcp/1235/p2p/{{ requester_output.content | from_json | community.general.json_query('PeerInfo.ID') }}"
55-
when: requester_output is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*")
56-
57-
- name: Set ipfs connect url
58-
ansible.builtin.set_fact:
59-
ipfs_connect: "/dns4/{{ ipfs_hostname }}/tcp/5001"
60-
when: ipfs_hostname is defined
61-
6223
- name: Download Bacalhau binary
6324
become: true
6425
ansible.builtin.unarchive:
@@ -72,17 +33,56 @@
7233
delay: 3
7334
until: bacalhau_unarchive is succeeded
7435

75-
- name: Install the Bacalhau systemd unit
76-
become: true
77-
ansible.builtin.template:
78-
src: "files/{{ bacalhau_node_type }}.service"
79-
dest: /etc/systemd/system
80-
notify:
81-
- Restart Bacalhau
36+
- name: Fetch AWS EC2 Metadata facts
37+
amazon.aws.ec2_metadata_facts:
8238

83-
- name: Ensure Bacalhau is running
84-
become: true
85-
ansible.builtin.service:
86-
name: "{{ bacalhau_node_type }}"
87-
state: started
88-
enabled: true
39+
- name: Print environment info
40+
ansible.builtin.debug:
41+
msg: "Running on environment: {{ ansible_ec2_tags_instance_Env }}"
42+
when: ansible_ec2_tags_instance_Env is defined
43+
44+
- name: Set fact when its prod node
45+
ansible.builtin.set_fact:
46+
requester_hostname: "requester.labdao.xyz"
47+
ipfs_hostname: "ipfs.labdao.xyz"
48+
when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower == "prod"
49+
50+
- name: Set fact when its non-prod node
51+
ansible.builtin.set_fact:
52+
requester_hostname: "requester.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz"
53+
ipfs_hostname: "ipfs.{{ ansible_ec2_tags_instance_Env | lower }}.labdao.xyz"
54+
when: ansible_ec2_tags_instance_Env is defined and ansible_ec2_tags_instance_Env | lower != "prod"
55+
56+
# Bacalhau PeerID, example `curl -s bacalhau.staging.labdao.xyz:1234/node_info | jq -r '.PeerInfo.ID'`
57+
- name: Determine requester bacalhau peer id
58+
ansible.builtin.uri:
59+
url: "http://{{ requester_hostname }}:1234/node_info"
60+
return_content: true
61+
register: requester_output
62+
when: requester_hostname is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*")
63+
64+
- name: Set requester_peer url
65+
ansible.builtin.set_fact:
66+
# requester_peer: /dns4/requester.staging.labdao.xyz/tcp/1235/p2p/QmeLa2fx2FMNDWbeY3UqjELc1MbKwNxggcmdBmLZepY6VK
67+
requester_peer: "/dns4/{{ requester_hostname }}/tcp/1235/p2p/{{ requester_output.content | from_json | community.general.json_query('PeerInfo.ID') }}"
68+
when: requester_output is defined and ansible_ec2_tags_instance_Type is defined and ansible_ec2_tags_instance_Type is match("compute.*")
69+
70+
- name: Set ipfs connect url
71+
ansible.builtin.set_fact:
72+
ipfs_connect: "/dns4/{{ ipfs_hostname }}/tcp/5001"
73+
when: ipfs_hostname is defined
74+
75+
- name: Install the Bacalhau systemd unit
76+
become: true
77+
ansible.builtin.template:
78+
src: "files/{{ bacalhau_node_type }}.service"
79+
dest: /etc/systemd/system
80+
notify:
81+
- Restart Bacalhau
82+
83+
- name: Ensure Bacalhau is running
84+
become: true
85+
ansible.builtin.service:
86+
name: "{{ bacalhau_node_type }}"
87+
state: started
88+
enabled: true

receptor/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM golang:1.18 as builder
2+
3+
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /global-bundle.pem
4+
5+
COPY . /app/
6+
RUN cd /app/ \
7+
&& CGO_ENABLED=0 go build -o /go/bin/receptor
8+
9+
FROM scratch
10+
11+
COPY --from=builder /go/bin/receptor /receptor
12+
COPY --from=builder /global-bundle.pem /global-bundle.pem
13+
14+
ENV PGHOST=postgres.example.com
15+
ENV PGUSER=receptor
16+
ENV PGDATABASE=receptor
17+
ENV PGSSLMODE=verify-ca
18+
ENV PGSSLROOTCERT=/global-bundle.pem
19+
20+
EXPOSE 8080
21+
22+
ENTRYPOINT ["/receptor"]

0 commit comments

Comments
 (0)