Skip to content

Commit 23e17e8

Browse files
committed
Align DO Marketplace build with partner validation
- Vendor cleanup/img-check scripts and run at end of Packer build - Disable DO build droplet extras and use small default size - Switch MOTD to update-motd.d and add submission checklist
1 parent 30575a6 commit 23e17e8

9 files changed

Lines changed: 988 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@v6
4040

41+
- name: Assert Marketplace scripts
42+
run: |
43+
test -f infra/digitalocean/marketplace/90-cleanup.sh
44+
test -f infra/digitalocean/marketplace/99-img-check.sh
45+
4146
- name: Setup Packer
4247
uses: hashicorp/setup-packer@v3
4348
with:

docs/deploy/digitalocean-marketplace.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,33 @@ just do-marketplace-validate
7676
just do-marketplace-build
7777
```
7878

79-
### Marketplace validation scripts
80-
81-
DigitalOcean provides `img_check.sh` and `cleanup.sh` in their Marketplace
82-
partners repo. Copy them into `infra/digitalocean/marketplace/` and run them
83-
against your built snapshot before submitting the image.
79+
## Marketplace submission checklist (aligned with `marketplace-partners`)
80+
81+
- [ ] Base image is supported (Ubuntu 24.04 LTS).
82+
- [ ] Build droplet uses smallest practical size (default `s-1vcpu-1gb`) to
83+
maximize customer plan compatibility.
84+
- [ ] Build droplet DO features disabled: monitoring, IPv6, private networking,
85+
and DO agent.
86+
- [ ] First-boot automation lives in `/var/lib/cloud/scripts/per-instance/` and
87+
is numerically prefixed (we use `001-opencode-cloud.sh`).
88+
- [ ] Security updates applied (handled by `90-cleanup.sh`).
89+
- [ ] No SSH keys / host keys / cloud-init instance state in the snapshot
90+
(handled by `90-cleanup.sh`).
91+
- [ ] Firewall configured (we enable + activate `ufw` during build).
92+
- [ ] DO image check passes (run automatically by Packer via `99-img-check.sh`;
93+
review WARN/FAIL output in the build logs).
94+
- [ ] MOTD uses `/etc/update-motd.d/99-*` (we write `99-opencode-cloud`).
95+
- [ ] Smoke test: create a droplet from the snapshot, wait for cloud-init,
96+
verify `deploy-status.json` exists and UI is reachable.
97+
98+
### Marketplace cleanup + validation scripts
99+
100+
This repo vendors DigitalOcean's Marketplace image cleanup + validation scripts
101+
from `digitalocean/marketplace-partners` into `infra/digitalocean/marketplace/`:
102+
103+
- `infra/digitalocean/marketplace/90-cleanup.sh`
104+
- `infra/digitalocean/marketplace/99-img-check.sh`
105+
106+
The Packer build runs these scripts as the final step to ensure the snapshot is
107+
ready for submission. Note that `90-cleanup.sh` zero-fills free disk space, so
108+
the final phase of `packer build` can take several minutes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# DigitalOcean Marketplace Image Validation Tool
4+
# © 2021 DigitalOcean LLC.
5+
# This code is licensed under Apache 2.0 license (see LICENSE.md for details)
6+
7+
set -o errexit
8+
9+
# Ensure /tmp exists and has the proper permissions before
10+
# checking for security updates
11+
# https://github.com/digitalocean/marketplace-partners/issues/94
12+
if [[ ! -d /tmp ]]; then
13+
mkdir /tmp
14+
fi
15+
chmod 1777 /tmp
16+
17+
if [ -n "$(command -v yum)" ]; then
18+
yum update -y
19+
yum clean all
20+
elif [ -n "$(command -v apt-get)" ]; then
21+
export DEBIAN_FRONTEND=noninteractive
22+
apt-get -y update
23+
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes
24+
apt-get -y autoremove
25+
apt-get -y autoclean
26+
fi
27+
28+
rm -rf /tmp/* /var/tmp/*
29+
history -c
30+
cat /dev/null > /root/.bash_history
31+
unset HISTFILE
32+
find /var/log -mtime -1 -type f -exec truncate -s 0 {} \;
33+
rm -rf /var/log/*.gz /var/log/*.[0-9] /var/log/*-????????
34+
rm -rf /var/lib/cloud/instances/*
35+
rm -f /root/.ssh/authorized_keys /etc/ssh/*key*
36+
touch /etc/ssh/revoked_keys
37+
chmod 600 /etc/ssh/revoked_keys
38+
39+
# Securely erase the unused portion of the filesystem
40+
GREEN='\033[0;32m'
41+
NC='\033[0m'
42+
printf "\n${GREEN}Writing zeros to the remaining disk space to securely
43+
erase the unused portion of the file system.
44+
Depending on your disk size this may take several minutes.
45+
The secure erase will complete successfully when you see:${NC}
46+
dd: writing to '/zerofile': No space left on device\n
47+
Beginning secure erase now\n"
48+
49+
dd if=/dev/zero of=/zerofile bs=4096 || rm /zerofile

0 commit comments

Comments
 (0)