Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
df57517
feat: migrate initialization to cloud-init with UFW and Docker hardening
google-labs-jules[bot] May 29, 2026
fd4eaec
feat: migrate initialization to cloud-init with UFW and Docker hardening
google-labs-jules[bot] May 29, 2026
5d8d9d3
feat: migrate initialization to cloud-init with iptables and Docker h…
google-labs-jules[bot] May 29, 2026
a28c72c
feat: configure unattended-upgrades to remove unused packages
google-labs-jules[bot] May 29, 2026
3842a10
feat: migrate initialization to cloud-init with iptables and Docker h…
google-labs-jules[bot] May 29, 2026
9ef16b5
feat: simplify cloud-init and enhance unattended-upgrades
google-labs-jules[bot] May 29, 2026
2016b28
feat: use native cloud-init keys for unattended-upgrades
google-labs-jules[bot] May 29, 2026
90a68b7
fix(cloud-init): replace invalid apt config with proper unattended-up…
yxtay May 29, 2026
70f5f46
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 29, 2026
5939c59
fix: apply megalinter fixes
pre-commit-ci[bot] May 29, 2026
ccfc250
refactor(cloud-init): remove unattended-upgrades config
yxtay May 29, 2026
9ca7dbb
Update cloud-init.yaml
yxtay May 29, 2026
962862b
Update cloud-init.yaml
yxtay May 29, 2026
e6516fe
Update cloud-init.yaml
yxtay May 29, 2026
81d0fba
style(readme): fix markdown list formatting
yxtay May 29, 2026
f008568
refactor(oci-rm): remove Oracle Linux support
yxtay May 29, 2026
bcc0406
refactor(oci-rm): remove instance_image_os variable
yxtay May 29, 2026
4459ae9
fix: apply megalinter fixes
yxtay May 29, 2026
066901b
fix(oci-rm): address PR review comments
yxtay May 29, 2026
4804189
fix: apply megalinter fixes
yxtay May 29, 2026
2227735
Update cloud-init.yaml
yxtay May 29, 2026
4ab6fcf
Update cloud-init.yaml
yxtay May 29, 2026
5106ab2
Update cloud-init.yaml
yxtay May 29, 2026
0380927
Update oci-rm/templates/cloud-init.yaml
yxtay May 30, 2026
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
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ submitting changes.
- Commits should follow conventional commits style.
- Formatting is enforced via pre-commit hooks for YAML, Shell scripts (shfmt),
and Markdown.

## Infrastructure Initialization

- **Cloud-init**: The instance initialization is handled via
`oci-rm/templates/cloud-init.yaml`.
- **Terraform Fallback**: `oci-rm/compute.tf` is configured to automatically
use the `cloud-init.yaml` template if the `user_data` variable is left
empty.
- **Networking**: `iptables` is used for port management instead of `ufw` to
ensure compatibility with Docker networking.
56 changes: 20 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ All variables have sensible defaults. Required inputs:

- **Compartment** — target OCI compartment
- **SSH Public Key** — key for instance access
- **Cloud-init Script** (optional) — paste `scripts/init.sh` to auto-install
Dokploy. This will be wrapped in a structured cloud-config.
- **Cloud-init Configuration** (optional) — paste `oci-rm/templates/cloud-init.yaml`
to customize the instance setup. Defaults to the provided template.

### Deploy via OCI Console (recommended)

Expand Down Expand Up @@ -102,49 +102,33 @@ watch -n 600 bash scripts/oci-rm-stack-apply.sh
*/10 * * * * STACK_ID=<stack-ocid> /path/to/scripts/oci-rm-stack-apply.sh
```

## Dokploy Setup on OCI
## Docker Setup on OCI

This repository includes a script to automate the setup of Dokploy on an Oracle
Cloud Infrastructure (OCI) Ubuntu instance.
This repository includes a cloud-init configuration to automate the setup of a
Docker-ready Ubuntu instance on Oracle Cloud Infrastructure (OCI).

### Initialization Script
### Cloud-init Configuration

The `scripts/init.sh` script performs the following actions:
The `oci-rm/templates/cloud-init.yaml` configuration performs the following actions:

1. Updates and upgrades system packages.
2. Configures `iptables` to allow traffic on essential ports:
- **80 (TCP)**: HTTP traffic.
- **443 (TCP/UDP)**: HTTPS traffic.
- **3000 (TCP)**: Dokploy Dashboard.
3. Ensures `iptables` rules are persistent across reboots using
`iptables-persistent`.
4. Installs Dokploy if it is not already present, or updates it if it is.
1. Configures `iptables` to allow traffic on essential ports:
- **80 (TCP)**: HTTP.
- **443 (TCP/UDP)**: HTTPS (including HTTP/3).
- **9443 (TCP)**: Portainer (to be added later).
1. Installs Docker using the official `get.docker.com` script.
1. Adds the `ubuntu` user to the `docker` group.
1. Reboots to apply all changes.

### Usage

#### As Cloud-init User Data

When creating a new OCI instance, you can provide the contents of
`scripts/init.sh` as the **Cloud-init script** (User Data) to automate the
entire setup process.
When creating a new OCI instance, the Terraform stack automatically uses
the template. You can also manually provide the contents of
`oci-rm/templates/cloud-init.yaml` as the **Cloud-init script** (User Data).

#### Manual Execution
#### Portainer

You can also run the script manually on an existing Ubuntu instance:

```bash
sudo ./scripts/init.sh
```

### Managing Deployments with Dokploy

Once Dokploy is installed, you can access the dashboard at
`http://<your-instance-ip>:3000`.

Dokploy allows you to easily manage and deploy:

- **Docker Compose Stacks**: Deploy complex multi-container applications by
providing your `docker-compose.yml` directly in the Dokploy interface.
- **Applications**: Deploy web applications from GitHub, GitLab, or Bitbucket.
- **Databases**: Easily provision and manage PostgreSQL, MySQL, MongoDB, and
Redis instances.
Portainer will be added in a future update to manage your containers easily via
a web interface.
12 changes: 6 additions & 6 deletions oci-rm/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data "oci_identity_availability_domain" "ad" {

data "oci_core_images" "instance_image" {
compartment_id = var.compartment_ocid
operating_system = var.instance_image_os
operating_system = "Canonical Ubuntu"
Comment thread
yxtay marked this conversation as resolved.
operating_system_version = var.instance_image_os_version
shape = "VM.Standard.A1.Flex"
sort_by = "TIMECREATED"
Expand All @@ -14,7 +14,7 @@ data "oci_core_images" "instance_image" {
lifecycle {
postcondition {
condition = length(self.images) > 0
error_message = "No images found for ${var.instance_image_os} ${var.instance_image_os_version} with shape VM.Standard.A1.Flex in this region/compartment."
error_message = "No images found for Canonical Ubuntu ${var.instance_image_os_version} with shape VM.Standard.A1.Flex in this region/compartment."
}
}
}
Expand Down Expand Up @@ -44,8 +44,8 @@ resource "oci_core_instance" "instance" {
boot_volume_size_in_gbs = var.boot_volume_size_in_gbs
}

metadata = merge(
{ ssh_authorized_keys = var.ssh_public_key },
var.user_data != "" ? { user_data = base64encode(var.user_data) } : {}
)
metadata = {
ssh_authorized_keys = var.ssh_public_key
user_data = base64encode(var.user_data != "" ? var.user_data : file("${path.module}/templates/cloud-init.yaml"))
}
Comment thread
yxtay marked this conversation as resolved.
}
2 changes: 1 addition & 1 deletion oci-rm/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
ssh_username = var.instance_image_os == "Canonical Ubuntu" ? "ubuntu" : "opc"
ssh_username = "ubuntu"
}
26 changes: 6 additions & 20 deletions oci-rm/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ variableGroups:
- instance_memory_in_gbs
- boot_volume_size_in_gbs

- title: "Operating System Selection"
- title: "Operating System"
variables:
- instance_image_os
- instance_image_os_version

- title: "Access and Automation"
Expand Down Expand Up @@ -100,26 +99,14 @@ variables:
default: 200
required: true

instance_image_os:
type: enum
title: "Operating System"
description: "The operating system to install on the instance."
enum:
- "Canonical Ubuntu"
- "Oracle Linux"
default: "Canonical Ubuntu"
required: true

instance_image_os_version:
type: enum
title: "OS Version"
description: "Ubuntu: 24.04, 22.04, 20.04 | Oracle Linux: 9, 8"
description: "Ubuntu version"
enum:
- "24.04"
- "22.04"
- "20.04"
- "9"
- "8"
default: "24.04"
required: true

Expand All @@ -138,11 +125,10 @@ variables:

user_data:
type: text
title: "Cloud-init Script (User Data)"
description: "Optional bash script to run on first boot. The script will be wrapped in a cloud-config runcmd."
title: "Cloud-init Configuration"
description: "Cloud-init configuration in YAML format (defaults to templates/cloud-init.yaml)."
required: false
default: ""

vcn_display_name:
type: string
title: "VCN Name"
Expand All @@ -167,8 +153,8 @@ variables:
tcp_ingress_ports:
type: string
title: "TCP Ingress Ports"
description: "Comma-separated list of TCP ports to allow ingress (e.g., 80,443,3000)."
default: "80,443,3000"
description: "Comma-separated list of TCP ports to allow ingress (e.g., 80,443,9443)."
default: "80,443,9443"
required: false

udp_ingress_ports:
Expand Down
26 changes: 26 additions & 0 deletions oci-rm/templates/cloud-init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#cloud-config
package_update: true
package_upgrade: true

packages:
- curl
- iptables-persistent

runcmd:
# Configure iptables
- [iptables, -I, INPUT, "1", -p, tcp, --dport, "80", -j, ACCEPT]
- [iptables, -I, INPUT, "1", -p, tcp, --dport, "443", -j, ACCEPT]
- [iptables, -I, INPUT, "1", -p, udp, --dport, "443", -j, ACCEPT]
- [iptables, -I, INPUT, "1", -p, tcp, --dport, "9443", -j, ACCEPT]
- [netfilter-persistent, save]

# Install Docker
- [curl, -fsSL, "https://get.docker.com", -o, /tmp/get-docker.sh]
- [sh, /tmp/get-docker.sh]
- [usermod, -aG, docker, ubuntu]
- [rm, /tmp/get-docker.sh]

power_state:
mode: reboot
message: Rebooting after cloud-init setup
condition: true
21 changes: 5 additions & 16 deletions oci-rm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,14 @@ variable "boot_volume_size_in_gbs" {
}
}

variable "instance_image_os" {
type = string
description = "Operating system"
default = "Canonical Ubuntu"

validation {
condition = contains(["Canonical Ubuntu", "Oracle Linux"], var.instance_image_os)
error_message = "instance_image_os must be 'Canonical Ubuntu' or 'Oracle Linux'."
}
}

variable "instance_image_os_version" {
type = string
description = "OS version (Ubuntu: 22.04, 20.04 | Oracle Linux: 9, 8)"
description = "Ubuntu OS version"
default = "24.04"

validation {
condition = contains(["24.04", "22.04", "20.04", "9", "8"], var.instance_image_os_version)
error_message = "instance_image_os_version must be one of: 24.04, 22.04, 20.04, 9, 8."
condition = contains(["24.04", "22.04", "20.04"], var.instance_image_os_version)
error_message = "instance_image_os_version must be one of: 24.04, 22.04, 20.04."
}
}

Expand All @@ -104,7 +93,7 @@ variable "ssh_source_cidr" {
variable "tcp_ingress_ports" {
type = string
description = "Comma-separated list of TCP ports to allow ingress"
default = "80,443,3000"
default = "80,443,9443"

validation {
condition = alltrue([for p in compact(split(",", replace(var.tcp_ingress_ports, " ", ""))) : can(tonumber(p)) && tonumber(p) >= 1 && tonumber(p) <= 65535])
Expand All @@ -125,7 +114,7 @@ variable "udp_ingress_ports" {

variable "user_data" {
type = string
description = "Cloud-init script to run on first boot (paste contents of scripts/init.sh to auto-install Dokploy)"
description = "Cloud-init configuration to run on first boot (defaults to templates/cloud-init.yaml)"
default = ""
}

Expand Down
47 changes: 0 additions & 47 deletions scripts/init.sh

This file was deleted.