Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add deployment solution to digital ocean app platform #430

Merged
merged 11 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/deploy-digitalocean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy to DigitalOcean Droplets

on:
push:
branches:
- master

jobs:
deploy:
# We just check the message of first commit as there is always just one commit because we squash into one before merging
# "commits" contains array of objects where one of the properties is commit "message"
# Release workflow will be skipped if release conventional commits are not used
if: |
startsWith( github.repository, 'asyncapi/' ) &&
(startsWith( github.event.commits[0].message , 'fix:' ) ||
startsWith( github.event.commits[0].message, 'fix!:' ) ||
startsWith( github.event.commits[0].message, 'feat:' ) ||
startsWith( github.event.commits[0].message, 'feat!:' ))
runs-on: ubuntu-latest
steps:
- name: Deploy to DigitalOcean Droplets
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /home/${{ secrets.USERNAME }}
if [ ! -d "deploy" ]; then
git clone https://github.com/asyncapi/server-api.git deploy
fi

cd deploy
git checkout master
git pull origin master

# Remove old docker containers
docker rm -f $(docker ps -a -q)
# Remove old docker images
docker rmi -f $(docker images -a -q)
# Remove old docker volumes
docker volume rm $(docker volume ls -q)

# Build new docker image
docker build -t asyncapi/server-api .

# Run new docker image
docker run -d -p 80:80 -p 443:443 --restart always --name asyncapi-server-api asyncapi/server-api
3 changes: 3 additions & 0 deletions deployments/droplets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.terraform
terraform.tfstate
terraform.tfstate.backup
26 changes: 26 additions & 0 deletions deployments/droplets/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions deployments/droplets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
Shurtu-gal marked this conversation as resolved.
Show resolved Hide resolved
required_version = ">= 1.0.0"

required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = ">= 2.0.0"
}
}
}

provider "digitalocean" {}

resource "digitalocean_droplet" "server-api" {
image = "ubuntu-23-10-x64"
name = "server-api"
region = "BLR1"
size = "s-1vcpu-1gb"
user_data = file("server-api.yaml")
}
4 changes: 4 additions & 0 deletions deployments/droplets/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "ip_address" {
value = digitalocean_droplet.server-api.ipv4_address
description = "The public IP address of your Droplet application."
}
28 changes: 28 additions & 0 deletions deployments/droplets/server-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#cloud-config
groups:
- ubuntu: [root,sys]

users:
- default
- name: asyncapi
gecos: AsyncAPI
primary-group: ubuntu
groups: users, admin
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
ssh-authorized-keys:
- # Add your public key here

runcmd:
- sudo apt-get update -y
- sudo apt install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
- sudo apt-get update -y
- sudo apt install docker-ce -y
- sudo systemctl status docker
# Add your user to the docker group to avoid using sudo when running docker
# NOTE: You need to logout and login again for this to take effect
- sudo systemctl enable docker
- sudo systemctl start docker
- sudo usermod -aG docker asyncapi
23 changes: 0 additions & 23 deletions deployments/k8s/.helmignore

This file was deleted.

7 changes: 0 additions & 7 deletions deployments/k8s/Chart.yaml

This file was deleted.

32 changes: 0 additions & 32 deletions deployments/k8s/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions deployments/k8s/templates/NOTES.txt

This file was deleted.

51 changes: 0 additions & 51 deletions deployments/k8s/templates/_helpers.tpl

This file was deleted.

69 changes: 0 additions & 69 deletions deployments/k8s/templates/deployment.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions deployments/k8s/templates/hpa.yaml

This file was deleted.

Loading
Loading