Skip to content

Commit

Permalink
Use docker compose v2
Browse files Browse the repository at this point in the history
  • Loading branch information
benjben committed Jan 6, 2025
1 parent af57686 commit 1d6dffe
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else

if [ "$SP_MINI_SIZE" == "large" ]
then
# prepare env vars for docker-compose
# prepare env vars for docker compose
echo -n > provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_MEM_SIZE=2560m" >> provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_HEAP_SIZE=1280m" >> provisioning/roles/docker/files/.env
Expand All @@ -47,7 +47,7 @@ else
fi
elif [ "$SP_MINI_SIZE" == "xlarge" ]
then
# prepare env vars for docker-compose
# prepare env vars for docker compose
echo -n > provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_MEM_SIZE=5g" >> provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_HEAP_SIZE=2560m" >> provisioning/roles/docker/files/.env
Expand All @@ -69,7 +69,7 @@ else
fi
elif [ "$SP_MINI_SIZE" == "xxlarge" ]
then
# prepare env vars for docker-compose
# prepare env vars for docker compose
echo -n > provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_MEM_SIZE=10g" >> provisioning/roles/docker/files/.env
echo "ELASTICSEARCH_HEAP_SIZE=5g" >> provisioning/roles/docker/files/.env
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ jobs:
cd $GITHUB_WORKSPACE/provisioning/resources/control-plane
go test *.go
- name: Provision a local Mini instance
run: ansible-playbook -i $GITHUB_WORKSPACE/provisioning/inventory $GITHUB_WORKSPACE/provisioning/local_setup.yml --connection=local --become

- id: 'auth'
if: startsWith(github.ref, 'refs/tags/')
uses: 'google-github-actions/auth@v0'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON_BASE64 }}'

- name: 'Set up Cloud SDK'
if: startsWith(github.ref, 'refs/tags/')
uses: 'google-github-actions/setup-gcloud@v0'
uses: 'google-github-actions/setup-gcloud@v2'

- name: SSH config for Ansible
run: mkdir ~/.ssh && echo -e "Host 127.0.0.1\nHostKeyAlgorithms +ssh-rsa\nPubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config
Expand Down
9 changes: 4 additions & 5 deletions Packerfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
"post-processors": [
[
{
"type": "googlecompute-export",
"type": "shell-local",
"only": ["googlecompute"],
"paths": [
"gs://snowplow-mini/{{user `gcp_image_name`}}.tar.gz"
],
"keep_input_artifact": true
"inline": [
"gcloud compute images export --destination-uri gs://snowplow-mini/{{user `gcp_image_name`}}.tar.gz --image {{user `gcp_image_name`}} --image-project snowplow-images"
]
},
{
"type": "shell-local",
Expand Down
8 changes: 4 additions & 4 deletions provisioning/resources/control-plane/restart_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func restartSPService(service string) (error, int) {
return nil, 200
} else {
if serviceName, ok := initMap[service]; ok {
restartCommandArgs := []string{"restart", serviceName}
cmd := exec.Command("docker-compose", restartCommandArgs...)
restartCommandArgs := []string{"compose", "restart", serviceName}
cmd := exec.Command("docker", restartCommandArgs...)
cmd.Dir = "/home/ubuntu/snowplow"
err := cmd.Run()
if err != nil {
Expand All @@ -48,8 +48,8 @@ func restartSPService(service string) (error, int) {
}

func restartSPServices() error {
restartCommandArgs := []string{"-f", "/home/ubuntu/snowplow/docker-compose.yml", "restart"}
cmd := exec.Command("docker-compose", restartCommandArgs...)
restartCommandArgs := []string{"compose", "-f", "/home/ubuntu/snowplow/docker-compose.yml", "restart"}
cmd := exec.Command("docker", restartCommandArgs...)
cmd.Dir = "/home/ubuntu/snowplow"
err := cmd.Run()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions provisioning/resources/init/snowplow_mini.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Type=oneshot
RemainAfterExit=true
WorkingDirectory=/home/ubuntu/snowplow
ExecStartPre=/usr/sbin/service docker restart
ExecStartPre=docker-compose down
ExecStart=docker-compose up -d
ExecStop=docker-compose down
ExecStartPre=docker compose down
ExecStart=docker compose up -d
ExecStop=docker compose down

[Install]
WantedBy=multi-user.target
24 changes: 6 additions & 18 deletions provisioning/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
---
- include_vars: ../../common_vars.yml

- name: Install ca-certificates curl gnupg
become: yes
shell: sudo apt-get install ca-certificates curl gnupg --yes

- name: Add Docker’s official GPG key
become: yes
shell: |
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
- name: Set up Docker repo
become: yes
shell: echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list
- name: Remove containerd
apt: name=containerd.io state=absent

- name: Install docker-compose
apt: name=docker-compose state=latest
- name: Install docker compose v2
apt: name=docker-compose-v2 state=latest

- name: Copy docker-compose.yml and its environment file
copy: src={{ item.src }} dest={{ item.dest }} owner=ubuntu group=ubuntu mode=0644
Expand All @@ -33,9 +21,9 @@
become: yes
shell: echo "vm.max_map_count=262144" >> /etc/sysctl.conf && service procps restart

- name: Start snowplow mini (docker-compose up)
- name: Start snowplow mini (docker compose up)
become: yes
shell: cd {{main_dir}} && docker-compose up -d && sleep 20
shell: cd {{main_dir}} && docker compose up -d && sleep 20

- name: Wait for Elasticsearch port 9200 to become open on the host, don't start checking for 10 seconds
wait_for:
Expand Down
2 changes: 1 addition & 1 deletion utils/scripts/user_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ password='password'
iglu_server_super_uid='deadbeef-dead-beef-dead-beefdeadbeef'

# DO NOT ALTER BELOW #
docker-compose -f /home/ubuntu/snowplow/docker-compose.yml restart iglu-server
docker compose -f /home/ubuntu/snowplow/docker-compose.yml restart iglu-server
sudo service snowplow_mini_control_plane_api restart

sleep 10
Expand Down

0 comments on commit 1d6dffe

Please sign in to comment.