Skip to content

Commit

Permalink
add digital ocean
Browse files Browse the repository at this point in the history
Signed-off-by: szaimen <[email protected]>
  • Loading branch information
szaimen committed Apr 15, 2022
1 parent d6a3600 commit 83d7cc9
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Remove the ssh force logout command
sed -e '/Match User root/d' \
-e '/.*ForceCommand.*droplet.*/d' \
-i /etc/ssh/sshd_config

systemctl restart ssh

# Install Nextcloud AIO
sudo docker run -d \
--name nextcloud-aio-mastercontainer \
--restart always \
-p 80:80 \
-p 8080:8080 \
-p 8443:8443 \
-e NEXTCLOUD_MOUNT=/mnt/ \
-e NEXTCLOUD_DATADIR=/mnt/ncdata \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
nextcloud/all-in-one:latest
67 changes: 67 additions & 0 deletions .build/digitalocean/marketplace-image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"variables": {
"do_token": "{{env `DIGITALOCEAN_TOKEN`}}",
"image_name": "nextcloud-20-04-snapshot-{{timestamp}}",
"apt_packages": "software-properties-common ufw",
"application_name": "Nextcloud",
"application_version": "1.0.0"
},
"sensitive-variables": ["do_token"],
"builders": [
{
"type": "digitalocean",
"api_token": "{{user `do_token`}}",
"image": "ubuntu-20-04-x64",
"region": "nyc3",
"size": "s-1vcpu-1gb",
"ssh_username": "root",
"snapshot_name": "{{user `image_name`}}"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"cloud-init status --wait"
]
},
{
"type": "file",
"source": "files/var/",
"destination": "/var/"
},
{
"type": "shell",
"environment_vars": [
"DEBIAN_FRONTEND=noninteractive",
"LC_ALL=C",
"LANG=en_US.UTF-8",
"LC_CTYPE=en_US.UTF-8"
],
"inline": [
"apt -qqy update",
"apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade",
"apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install {{user `apt_packages`}}",
"apt-get -qqy clean"
]
},
{
"type": "shell",
"environment_vars": [
"application_name={{user `application_name`}}",
"application_version={{user `application_version`}}",
"DEBIAN_FRONTEND=noninteractive",
"LC_ALL=C",
"LANG=en_US.UTF-8",
"LC_CTYPE=en_US.UTF-8"
],
"scripts": [
"scripts/01-nextcloud-aio.sh",
"scripts/02-ufw.sh",
"scripts/03-force-ssh-logout.sh",
"scripts/90-cleanup.sh",
"scripts/99-img-check.sh"
]
}
]
}
1 change: 1 addition & 0 deletions .build/digitalocean/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Digital Ocean build was created following https://marketplace.digitalocean.com/vendors#:~:text=how%20to%20list%20your%201-click%20application%20on%20the%20digitalocean%20marketplace and https://github.com/digitalocean/marketplace-partners#getting-started-creating-your-droplet-based-1-click-app
11 changes: 11 additions & 0 deletions .build/digitalocean/scripts/01-nextcloud-aio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/bash

# Install docker
curl -fsSL get.docker.com | sudo sh

# Adjust permissions
sudo mkdir -p /mnt/ncdata
sudo chown -R 33:0 /mnt/ncdata

# Get Nextcloud AIO
sudo docker pull nextcloud/all-in-one:latest
11 changes: 11 additions & 0 deletions .build/digitalocean/scripts/02-ufw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

ufw limit ssh
ufw allow http
ufw allow https
ufw allow 3478/tcp
ufw allow 3478/udp
ufw allow 8080/tcp
ufw allow 8443/tcp

ufw --force enable
3 changes: 3 additions & 0 deletions .build/digitalocean/scripts/03-force-ssh-logout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

curl -fsSL https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/03-force-ssh-logout.sh | sudo bash
3 changes: 3 additions & 0 deletions .build/digitalocean/scripts/90-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

curl -fsSL https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/90-cleanup.sh | sudo bash
3 changes: 3 additions & 0 deletions .build/digitalocean/scripts/99-img-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

curl -fsSL https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/99-img-check.sh | sudo bash
1 change: 1 addition & 0 deletions .build/linode/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Linode build files are here: https://github.com/linode/Marketplace-Apps/tree/master/Nextcloud. They were created following https://www.linode.com/de/marketplace/app-partners/#submit
26 changes: 26 additions & 0 deletions .github/workflows/publish-to-digitalocean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish to Digital Ocean

on:
workflow_dispatch:
branches: [ main ]

jobs:
publish_to_digitalocean:
runs-on: ubuntu-latest
name: Publish image to Digital Ocean

steps:
- uses: actions/checkout@v3
- name: Install Packer
run: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install packer
packer --version
- name: Create Image
run: |
cd ./build/digitalocean
chmod +x -R ./files/var/lib/cloud/scripts
export DIGITALOCEAN_TOKEN=${{ secrets.DIGITALOCEAN_TOKEN }}
packer validate marketplace-image.json
packer build marketplace-image.json

0 comments on commit 83d7cc9

Please sign in to comment.