Skip to content

Commit 8c53fc5

Browse files
add GCP to heroku migration docs (#279)
* add GCP to heroku migration docs * DO notes in heroku migration doc * add Supporter Providers to more concept pages * one off jobs doc
1 parent 249e5d9 commit 8c53fc5

File tree

7 files changed

+263
-7
lines changed

7 files changed

+263
-7
lines changed

docs/concepts/configuration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,12 @@ Here are the different ways sensitive config values are stored depending on the
8989
:::info
9090
Please note that while Defang supports setting sensitive config, it does not support the [`secrets`](https://docs.docker.com/reference/compose-file/secrets/) top-level element as seen in the Compose specification. Please see our [Compose](/docs/concepts/compose) page for more details.
9191
:::
92+
93+
## Supported Providers
94+
95+
| Provider | Config Support |
96+
|----------------|:--------------:|
97+
| Playground | ✅ |
98+
| AWS | ✅ |
99+
| DigitalOcean | ✅ |
100+
| GCP | ✅ |

docs/concepts/estimation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,12 @@ Now that you have estimated the costs associated with your project. You are read
6464
defang compose up [--provider aws|gcp|digitalocean] [--mode affordable|balanced|high_availability]
6565
```
6666

67+
## Supported Providers
68+
69+
| Provider | Estimation Support |
70+
|----------------|:------------------:|
71+
| Playground ||
72+
| AWS ||
73+
| DigitalOcean ||
74+
| GCP ||
75+

docs/concepts/one_off_jobs.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: One-off Jobs
3+
description: Defang enables you to run one-off jobs during your deployment workflow.
4+
sidebar_position: 280
5+
---
6+
7+
# One-off Jobs
8+
Defang enables you to run one-off jobs during your deployment workflow. One-off jobs are commands that run at specific points in the deployment process, such as after your database is ready but before your application starts.
9+
10+
One-off jobs are run a single time, and failure to run a one-off job will cause the entire deployment to fail.
11+
12+
:::info
13+
Currently, AWS and GCP are supported for one-off jobs. Support for Digital Ocean is coming soon.
14+
:::
15+
16+
## When should one-off jobs be used?
17+
One-off jobs are useful for running commands that need to be executed before your application starts. Common use cases include:
18+
19+
- Database migrations
20+
- Warming or cleaning caches
21+
- Running build scripts
22+
23+
## How to configure one-off jobs
24+
25+
One-off jobs can be configured in your `compose.yaml` file as services with a [Restart Policy](https://docs.docker.com/reference/compose-file/services/#restart) set to `"no"`.
26+
27+
In the example below, we define a one-off job called `release` that runs a script called `release.sh`. This job will run once during the deployment process. It will be run concurrently with the `web` service.
28+
29+
<table width="100%">
30+
<thead>
31+
<tr>
32+
<th><code>compose.yaml</code></th>
33+
<th>Workflow</th>
34+
</tr>
35+
</thead>
36+
<tbody>
37+
<tr>
38+
<td valign="top">
39+
40+
```yaml
41+
services:
42+
app:
43+
build: .
44+
ports:
45+
- "80:80"
46+
47+
release:
48+
build: .
49+
command: ["./release.sh"]
50+
restart: "no"
51+
```
52+
53+
</td>
54+
<td valign="top">
55+
56+
```mermaid
57+
flowchart LR
58+
subgraph workspace["Deployment Workflow"]
59+
deployment_start
60+
app
61+
release
62+
deployment_complete
63+
64+
deployment_start --> app
65+
deployment_start --> release
66+
app --> deployment_complete
67+
release --> deployment_complete
68+
end
69+
```
70+
71+
</td>
72+
</tr>
73+
</tbody>
74+
</table>
75+
76+
### How to specify job dependencies
77+
78+
You can specify when the job should run by using [`depends_on`](https://docs.docker.com/reference/compose-file/services/#depends_on) to define dependencies on other services. For example, when running database migrations, you would typically want to ensure that the database service is ready before executing the migration job.
79+
80+
Here is an example configuration for a one-off job that runs database migrations after the database service is ready:
81+
82+
<table width="100%">
83+
<thead>
84+
<tr>
85+
<th><code>compose.yaml</code></th>
86+
<th>Workflow</th>
87+
</tr>
88+
</thead>
89+
<tbody>
90+
<tr>
91+
<td valign="top">
92+
93+
```yaml
94+
services:
95+
db:
96+
image: postgres:latest
97+
98+
migrate:
99+
build: .
100+
command: ["./migrate.sh"]
101+
depends_on:
102+
- db
103+
restart: "no"
104+
105+
web:
106+
build: .
107+
ports:
108+
- "80:80"
109+
depends_on:
110+
- migrate
111+
```
112+
113+
</td>
114+
<td valign="top">
115+
116+
```mermaid
117+
flowchart LR
118+
subgraph workspace["Deployment Workflow"]
119+
deployment_start
120+
db
121+
web
122+
migrate
123+
deployment_complete
124+
125+
deployment_start --> db
126+
db --> migrate
127+
migrate --> web
128+
web --> deployment_complete
129+
end
130+
```
131+
132+
</td>
133+
</tr>
134+
</tbody>
135+
</table>
136+
137+
## How do one-off jobs work under the hood?
138+
139+
One off jobs are deployed as temporary containers on the same infrastructure as your main services. They are deployed as separate containers to ensure that they do not interfere with the main application services, so resources can be configured independently. They will share the same network and security groups as your other services, allowing them to communicate with your application and database services as needed.
140+
141+
### Supported Providers
142+
143+
| Provider | Release Task Support |
144+
|----------------|:--------------------:|
145+
| Playground ||
146+
| AWS ||
147+
| DigitalOcean ||
148+
| GCP ||
149+
150+

docs/concepts/railpack.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,12 @@ services:
144144
reservations:
145145
memory: 512M
146146
```
147+
148+
## Supported Providers
149+
150+
| Provider | Railpack Support |
151+
|----------------|:----------------:|
152+
| Playground | ❌ |
153+
| AWS | ✅ |
154+
| DigitalOcean | ❌ |
155+
| GCP | ✅ |

docs/concepts/resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Defang uses `shm_size` to configure both the memory and disk space available to
6767

6868
The default `shm_size` values for each platform are as follows. More or less may be specified.
6969

70-
| Platform | `shm_size` Minimum |
70+
| Provider | `shm_size` Minimum |
7171
| ------------- | ------------------ |
7272
| AWS | 16G |
7373
| Digital Ocean | 8G |

docs/concepts/scaling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ Auto-scaling systems typically rely on:
6565
- If average CPU > 85% for 5 minutes → scale up by 2 instances.
6666
- **Cooldown Periods**: Delays between scaling events to prevent rapid, repeated changes (flapping).
6767
68-
### Supported Platforms
68+
### Supported Providers
6969
70-
| Platform | Auto-Scaling Support |
71-
|----------------|:----------------------:|
70+
| Provider | Auto-Scaling Support |
71+
|----------------|:--------------------:|
7272
| Playground | ❌ |
7373
| AWS | ✅ |
7474
| DigitalOcean | ❌ |

docs/tutorials/migrating-from-heroku.md

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This tutorial will guide you through the process of migrating your Heroku applic
1313
* [The Heroku CLI (optional, but recommended)](https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli)
1414
* Cloud Account Credentials
1515
* [AWS](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-authentication.html)
16-
* [GCP](https://cloud.google.com/docs/authentication/set-up-adc-local-dev-environment) (coming soon)
16+
* [GCP](https://cloud.google.com/docs/authentication/set-up-adc-local-dev-environment)
1717

1818
:::tip
1919
**Do I need a Dockerfile?**
@@ -167,7 +167,7 @@ Now all you need to do is deploy your application to the cloud.
167167
168168
### Deploying to AWS
169169
170-
If you're deploying to AWS, you'll need to invoke `defang compose up` with your AWS access credentials in the environment:
170+
If you're deploying to AWS, you'll need to invoke `defang compose up --provider aws` with your AWS access credentials in the environment:
171171

172172
<details>
173173
<summary>
@@ -285,7 +285,86 @@ See our full tutorial on [deploying to AWS](/docs/tutorials/deploy-to-aws).
285285
286286
### Deploying to GCP
287287
288-
GCP support for deployments without Dockerfiles coming soon.
288+
If you're deploying to GCP, you'll need to invoke `defang compose up --provider gcp` with your GCP access credentials in the environment:
289+
290+
<details>
291+
<summary>
292+
Run the following command
293+
```
294+
GCP_PROJECT_ID=my-project-123456 defang compose up --provider gcp
295+
```
296+
</summary>
297+
```
298+
* Using Google Cloud Platform provider from command line flag
299+
! Defang cannot monitor status of the following managed service(s): [postgres release].
300+
To check if the managed service is up, check the status of the service which depends on it.
301+
! service "postgres": missing memory reservation; using provider-specific defaults. Specify deploy.resources.reservations.memory to avoid out-of-memory errors
302+
! service "web": ingress port without healthcheck defaults to GET / HTTP/1.1
303+
* Packaging the project files for web at /Users/defang/wk/vast-badlands
304+
* Uploading the project files for web
305+
* Setting up defang CD in GCP project my-project-123456, this could take a few minutes
306+
* Packaging the project files for release at /Users/defang/wk/vast-badlands
307+
* Uploading the project files for release
308+
* Tailing logs for deployment ID fgdh4ct0hopz ; press Ctrl+C to detach:
309+
* Showing only build logs and runtime errors. Press V to toggle verbose mode.
310+
2025-09-08T10:28:08.634-04:00 cd ** Update started for stack beta
311+
2025-09-08T10:28:17.990-04:00 cd ** Updating service "postgres"
312+
2025-09-08T10:28:44.773-04:00 cd ** Building image for "release"...
313+
2025-09-08T10:28:58.012-04:00 cd ** Building image for "web"...
314+
2025-09-08T10:47:02.479-04:00 release I, [2025-09-08T14:47:02.409371 #1] INFO -- : Migrating to CreateMembers (20240416182733)
315+
2025-09-08T10:47:02.479-04:00 release == 20240416182733 CreateMembers: migrating ====================================
316+
2025-09-08T10:47:02.479-04:00 release -- create_table(:members)
317+
2025-09-08T10:47:02.479-04:00 release -> 0.0073s
318+
2025-09-08T10:47:02.479-04:00 release == 20240416182733 CreateMembers: migrated (0.0073s) ===========================
319+
2025-09-08T10:47:02.479-04:00 release I, [2025-09-08T14:47:02.432075 #1] INFO -- : Migrating to DeviseCreateUsers (20240417165503)
320+
2025-09-08T10:47:02.479-04:00 release == 20240417165503 DeviseCreateUsers: migrating ================================
321+
2025-09-08T10:47:02.479-04:00 release -- create_table(:users)
322+
2025-09-08T10:47:02.479-04:00 release -> 0.0080s
323+
2025-09-08T10:47:02.479-04:00 release -- add_index(:users, :email, {:unique=>true})
324+
2025-09-08T10:47:02.479-04:00 release -> 0.0022s
325+
2025-09-08T10:47:02.479-04:00 release -- add_index(:users, :reset_password_token, {:unique=>true})
326+
2025-09-08T10:47:02.479-04:00 release -> 0.0021s
327+
2025-09-08T10:47:02.479-04:00 release == 20240417165503 DeviseCreateUsers: migrated (0.0124s) =======================
328+
2025-09-08T10:47:02.479-04:00 release I, [2025-09-08T14:47:02.458370 #1] INFO -- : Migrating to AddUserIdToMembers (20240417202202)
329+
2025-09-08T10:47:02.479-04:00 release == 20240417202202 AddUserIdToMembers: migrating ===============================
330+
2025-09-08T10:47:02.479-04:00 release -- add_column(:members, :user_id, :integer)
331+
2025-09-08T10:47:02.479-04:00 release -> 0.0044s
332+
2025-09-08T10:47:02.479-04:00 release -- add_index(:members, :user_id)
333+
2025-09-08T10:47:02.479-04:00 release -> 0.0019s
334+
2025-09-08T10:47:02.479-04:00 release == 20240417202202 AddUserIdToMembers: migrated (0.0064s) ======================
335+
2025-09-08T10:48:16.157-04:00 web => Booting Puma
336+
2025-09-08T10:48:16.157-04:00 web => Rails 7.1.3.2 application starting in production
337+
2025-09-08T10:48:16.157-04:00 web => Run `bin/rails server --help` for more startup options
338+
2025-09-08T10:48:18.625-04:00 web [1] Puma starting in cluster mode...
339+
2025-09-08T10:48:18.625-04:00 web [1] * Puma version: 6.4.2 (ruby 3.3.4-p94) ("The Eagle of Durango")
340+
2025-09-08T10:48:18.625-04:00 web [1] * Min threads: 5
341+
2025-09-08T10:48:18.625-04:00 web [1] * Max threads: 5
342+
2025-09-08T10:48:18.625-04:00 web [1] * Environment: production
343+
2025-09-08T10:48:18.626-04:00 web [1] * Master PID: 1
344+
2025-09-08T10:48:18.626-04:00 web [1] * Workers: 2
345+
2025-09-08T10:48:18.626-04:00 web [1] * Restarts: (✔) hot (✔) phased
346+
2025-09-08T10:48:18.626-04:00 web [1] * Listening on http://0.0.0.0:5000
347+
2025-09-08T10:48:18.627-04:00 web [1] Use Ctrl-C to stop
348+
```
349+
</details>
350+
351+
### Deploying to DigitalOcean
352+
353+
If you're deploying to GCP, you'll need to invoke `defang compose up --provider digitalocean` with your DigitalOcean access credentials in the environment:
354+
355+
:::warning
356+
Some Heroku applications may require some manual adjustments to be deployed to DigitalOcean with Defang.
357+
Dockerfiles are required for deployments to DigitalOcean, so you may need to create one if your application does not already have one. Support for automatic Dockerfile generation is coming soon with [Railpack](/docs/concepts/railpack.md).
358+
Defang also does not yet support [one-off jobs](/docs/concepts/one_off_jobs) on DigitalOcean, so you will need to modify your services to run these tasks during initialization.
359+
:::
360+
361+
```
362+
export DIGITALOCEAN_TOKEN=your_digitalocean_token
363+
export SPACES_ACCESS_KEY_ID=your_spaces_access_key_id
364+
export SPACES_SECRET_ACCESS_KEY=your_spaces_secret_access_key
365+
$ defang compose up --provider digitalocean
366+
```
367+
289368
290369
## Step 3 - Migrating your data
291370

0 commit comments

Comments
 (0)