Skip to content

Commit

Permalink
Use Ubuntu 22.04 as base image and in Github Actions (close #381)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjben committed Jul 4, 2023
1 parent 91a39d6 commit 7c9fdea
Show file tree
Hide file tree
Showing 34 changed files with 63 additions and 525 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
name: Test and Publish Mini
name: Publish Mini

on:
push:

jobs:
test:
name: Test and publish artifacts
runs-on: ubuntu-18.04
publish:
name: Publish artifacts
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check Go version
run: go version

- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y language-pack-en python-pip libffi-dev libssl-dev python-dev
sudo pip install --upgrade pip
sudo pip install markupsafe==1.1.1 setuptools==40.8.0 ansible==2.8.1 paramiko==1.16.0
- uses: actions/checkout@v3

- name: Provision a local Mini instance
run: ansible-playbook -i $GITHUB_WORKSPACE/provisioning/inventory $GITHUB_WORKSPACE/provisioning/local_setup.yml --connection=local --become
Expand All @@ -35,15 +24,13 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
uses: 'google-github-actions/setup-gcloud@v0'

- name: Extract tag from ref
if: startsWith(github.ref, 'refs/tags/')
id: get_tag
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | sed "s/refs\/tags\///")
- name: SSH config for Ansible
run: mkdir ~/.ssh && echo -e "Host 127.0.0.1\nHostKeyAlgorithms +ssh-rsa\nPubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config

- name: Publish artifact based on cloud and size
if: startsWith(github.ref, 'refs/tags/')
env:
AWS_DEPLOY_ACCESS_KEY: ${{ secrets.AWS_DEPLOY_ACCESS_KEY }}
AWS_DEPLOY_SECRET_KEY: ${{ secrets.AWS_DEPLOY_SECRET_KEY }}
GOOGLE_APPLICATION_CREDENTIALS_JSON_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON_BASE64 }}
run: $GITHUB_WORKSPACE/.github/workflows/deploy.sh ${{ steps.get_tag.outputs.VERSION }}
run: $GITHUB_WORKSPACE/.github/workflows/deploy.sh ${{ github.ref_name }}
6 changes: 3 additions & 3 deletions Packerfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"filters": {
"virtualization-type": "hvm",
"architecture": "x86_64",
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
"name": "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"ssh_username": "ubuntu",
"tags": {
"OS_Version": "Ubuntu-18.04",
"OS_Version": "Ubuntu-22.04",
"Release": "{{user `aws_version`}}"
},
"type": "amazon-ebs"
Expand All @@ -32,7 +32,7 @@
"image_name": "{{user `gcp_image_name`}}",
"machine_type": "{{user `gcp_machine_type`}}",
"project_id": "snowplow-images",
"source_image_family": "ubuntu-1804-lts",
"source_image_family": "ubuntu-2204-lts",
"ssh_username": "ubuntu",
"zone": "us-central1-a"
}
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/bionic64"
config.vm.box = "ubuntu/jammy64"
config.vm.hostname = "snowplow-mini"
config.ssh.forward_agent = true

Expand Down
25 changes: 0 additions & 25 deletions integration/integration_test.sh

This file was deleted.

2 changes: 1 addition & 1 deletion provisioning/local_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all

roles:
- ansible-go
- go
- nodejs
- typescript
- packer
Expand Down
4 changes: 2 additions & 2 deletions provisioning/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# This playbook is used for provisioning of the AMI
# UI and executables file are made ready in the vagrant environment
# UI and executables file are made ready locally in Github Actions
# They are only copied into the AMI here
- name: apply all scripts
hosts: all
Expand All @@ -10,4 +10,4 @@
- sp_mini_4_setup_apps
- sp_mini_6_copy_ui_folders
- sp_mini_7_setup_init
- docker
- docker
6 changes: 3 additions & 3 deletions provisioning/resources/control-plane/restart_services.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-2018 Snowplow Analytics Ltd.
* Copyright (c) 2016-2023 Snowplow Analytics Ltd.
* All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
Expand Down Expand Up @@ -44,7 +44,7 @@ func restartSPService(service string) (error, int) {
} else {
if serviceName, ok := initMap[service]; ok {
restartCommandArgs := []string{"restart", serviceName}
cmd := exec.Command("/usr/local/bin/docker-compose", restartCommandArgs...)
cmd := exec.Command("docker-compose", restartCommandArgs...)
cmd.Dir = "/home/ubuntu/snowplow"
err := cmd.Run()
if err != nil {
Expand All @@ -58,7 +58,7 @@ func restartSPService(service string) (error, int) {

func restartSPServices() error {
restartCommandArgs := []string{"-f", "/home/ubuntu/snowplow/docker-compose.yml", "restart"}
cmd := exec.Command("/usr/local/bin/docker-compose", restartCommandArgs...)
cmd := exec.Command("docker-compose", 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=/usr/local/bin/docker-compose down
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down
ExecStartPre=docker-compose down
ExecStart=docker-compose up -d
ExecStop=docker-compose down

[Install]
WantedBy=multi-user.target
37 changes: 0 additions & 37 deletions provisioning/roles/ansible-go/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions provisioning/roles/ansible-go/defaults/main.yml

This file was deleted.

1 change: 0 additions & 1 deletion provisioning/roles/ansible-go/files/go-bin.sh

This file was deleted.

2 changes: 0 additions & 2 deletions provisioning/roles/ansible-go/files/go-path.sh

This file was deleted.

40 changes: 0 additions & 40 deletions provisioning/roles/ansible-go/meta/main.yml

This file was deleted.

42 changes: 0 additions & 42 deletions provisioning/roles/ansible-go/tasks/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions provisioning/roles/ansible-go/vars/main.yml

This file was deleted.

3 changes: 2 additions & 1 deletion provisioning/roles/common_vars.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
main_dir: "/home/ubuntu/snowplow"
home_dir: "/home/ubuntu"
main_dir: "{{home_dir}}/snowplow"
configs_dir: "{{main_dir}}/configs"
staging_dir: "{{main_dir}}/staging"
executables_dir: "{{main_dir}}/bin"
Expand Down
29 changes: 13 additions & 16 deletions provisioning/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
---
- include_vars: ../../common_vars.yml

- name: Setup the docker repository and install docker
- name: Install ca-certificates curl gnupg
become: yes
shell: |
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common --yes
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update && apt-get install docker-ce --yes
shell: sudo apt-get install ca-certificates curl gnupg

- name: Download docker-compose
- name: Add Docker’s official GPG key
become: yes
shell: curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
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: Apply executable permissions to the docker-compose binary
- name: Set up Docker repo
become: yes
args:
warn: false
shell: chmod +x /usr/local/bin/docker-compose
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: Install docker-compose
apt: name=docker-compose 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 @@ -28,15 +27,13 @@

- name: Create & set permissions of elasticsearch data directory
become: yes
args:
warn: false
shell: rm -rf {{main_dir}}/elasticsearch/data && mkdir {{main_dir}}/elasticsearch/data && chown -R 1000:1000 {{main_dir}}/elasticsearch/data

- name: Increase mmap count to recommended 262144 for Elasticsearch
become: yes
shell: echo "vm.max_map_count=262144" >> /etc/sysctl.conf && service procps restart

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

Expand Down
3 changes: 3 additions & 0 deletions provisioning/roles/go/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Install Go
apt: name=golang-go state=latest
2 changes: 0 additions & 2 deletions provisioning/roles/nodejs/.gitignore

This file was deleted.

Loading

0 comments on commit 7c9fdea

Please sign in to comment.