You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Github Actions with prebuilt Container Images (Optional)
241
+
242
+
Deploying an application to DigitalOcean can be done using prebuilt container images stored in a container registry such as [Digital Ocean Container Registry](https://www.digitalocean.com/products/container-registry). Using prebuilt images helps speed up deployment, eliminate the need to install dependencies on the server, and ensure build reproducibility.
243
+
244
+
To use prebuilt container images, navigate to the DigitalOcean Container Registry tab and click the Create a Container Registry button.
1. Select the Basic plan, choose the region that matches your app’s region, specify a name for the container registry, and click Create Registry.
249
+
250
+

251
+
252
+
2. Add two new GitHub Actions workflows to build and push updated images so they can be attached to your DigitalOcean Apps. Don’t forget to replace `registry.digitalocean.com/ship-demo/ship-demo-${{ matrix.app_name }}:${{ github.sha }}` with your own values from DigitalOcean.
253
+
254
+
**API Build and Push Docker Image GH Action:**
255
+
```yaml
256
+
name: Build and Push Staging API Image to DigitalOcean
3. Add 3 new github secrets: `DO_USERNAME` (the email of your DigitalOcean account), `DO_WEB_STAGING_APP_NAME` (the name of the web app) and `DO_API_STAGING_APP_NAME` (the name of the API app). And run 2 new workflows manually to push the initial images to the DigitalOcean Container Registry.
365
+
366
+

367
+
368
+

369
+
370
+
4. Navigate to your DigitalOcean Container Registry. You should see 4 newly added repositories, as shown in the screenshot below.
371
+
372
+

373
+
374
+
5. Navigate to Application Spec `(settings tab)`. Remove `dockerfile_path`, `github`, `source_dir` variables for migrator, scheduler and api. Migrator is placed in the `jobs` section. The scheduler is placed in the `workers` section. The api is placed in the `services` section. You can also find it by name of the resource.
375
+
376
+
6. Add `image` variable for api, migrator and scheduler. You can check image `tag` in your DigitalOcean Container Registry.
377
+
378
+
**Image configuration :**
379
+
```yaml
380
+
image:
381
+
registry: YOUR_DO_REGISTRY_NAME
382
+
registry_type: DOCR
383
+
repository: YOUR_DO_REPOSITORY_NAME
384
+
tag: YOUR_RECENT_IMAGE_TAG
385
+
```
386
+
387
+

388
+
389
+

390
+
391
+

392
+
393
+
7. Do the same actions for web app.
394
+
395
+

396
+
397
+
8. Replace the old deployment action with the new one and remove old two actions: `Build and Push Staging API Image to DigitalOcean` and `Build and Push Staging Web Image to DigitalOcean`.
The name of the environment variable for the image tag must meet this requirement IMAGE_TAG_$component-name.
552
+
</Note>
553
+
554
+
For production deployments, **prebuilt container images** provide better consistency and reliability. Prebuilt container images in GitHub Actions deploy faster than DigitalOcean-managed builds because the images are built in CI/CD and pushed ready-to-use, while DO builds them during deployment. See the comparison below.
Digital Ocean Apps allows configuring additional resources within one application, which can serve as background workers and jobs, and a scheduler to run before/after the deployment process.
0 commit comments