Skip to content

Commit 47275a4

Browse files
committed
fix: Fix PR comments
1 parent 436dc0d commit 47275a4

File tree

3 files changed

+395
-316
lines changed

3 files changed

+395
-316
lines changed

docs/deployment/digital-ocean-apps-iac.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: "Digital Ocean Apps (IaC)"
33
---
44

5+
import GithubActionsWithPrebuiltImagesSnippet from '/snippets/github-actions-with-prebuilt-docker-images-for-do.mdx';
6+
57
There is a simplified deployment type without Kubernetes. This type is **recommended** for most new applications because it allows you to set up infrastructure faster and doesn't require additional DevOps knowledge from the development team. You can switch to a more complex Kubernetes solution when your application will be at scale.
68

79
It's a step-by-step Ship deployment guide. We will use the [Digital Ocean Apps](https://www.digitalocean.com/products/app-platform) and [GitHub Actions](https://github.com/features/actions) for automated deployment. [Mongo Atlas](https://www.mongodb.com/) and [Redis Cloud](https://redis.com/try-free/) for databases deployment, [Cloudflare](https://www.cloudflare.com/) for DNS and SSL configuration and [Pulumi](https://www.pulumi.com/) for Infrastructure as Code
@@ -273,6 +275,9 @@ Done! Application deployed and can be accessed by provided domain.
273275

274276
![Deployed application](/images/deployed-application.png)
275277

278+
## Github Actions with prebuilt Container Images (Optional)
279+
<GithubActionsWithPrebuiltImagesSnippet/>
280+
276281
## Logging (optional)
277282
### Build-in
278283

docs/deployment/digital-ocean-apps.mdx

Lines changed: 3 additions & 316 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: "Digital Ocean Apps"
33
---
44

5+
import GithubActionsWithPrebuiltImagesSnippet from '/snippets/github-actions-with-prebuilt-docker-images-for-do.mdx';
6+
57
There is a simplified deployment type without Kubernetes. This type is **recommended** for most new applications because it allows you to set up infrastructure faster and doesn't require additional DevOps knowledge from the development team. You can switch to a more complex Kubernetes solution when your application will be at scale.
68

79
<Tip>
@@ -238,322 +240,7 @@ Done! Application deployed and can be accessed by provided domain.
238240
![Deployed application](/images/deployed-application.png)
239241

240242
## 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.
245-
246-
![Digital Ocean Container Registry](/images/create-digital-ocean-container-registry.png)
247-
248-
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-
![Select DO container registry plan](/images/select-do-registry-plan.png)
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
257-
258-
on:
259-
push:
260-
branches: [main]
261-
paths:
262-
- "apps/api/**"
263-
- "packages/**"
264-
workflow_dispatch:
265-
266-
permissions:
267-
contents: read
268-
packages: write
269-
270-
jobs:
271-
build:
272-
name: Build and Push Docker Images
273-
runs-on: ubuntu-latest
274-
strategy:
275-
matrix:
276-
include:
277-
- app_name: api
278-
dockerfile: apps/api/Dockerfile
279-
- app_name: migrator
280-
dockerfile: apps/api/Dockerfile.migrator
281-
- app_name: scheduler
282-
dockerfile: apps/api/Dockerfile.scheduler
283-
steps:
284-
- name: Checkout code
285-
uses: actions/checkout@v4
286-
287-
- name: Set up QEMU
288-
uses: docker/setup-qemu-action@v3
289-
290-
- name: Set up Docker Buildx
291-
uses: docker/setup-buildx-action@v3
292-
293-
- name: Login to Docker Hub
294-
uses: docker/login-action@v3
295-
with:
296-
registry: registry.digitalocean.com
297-
username: ${{ secrets.DO_USERNAME }}
298-
password: ${{ secrets.DO_ACCESS_TOKEN }}
299-
300-
- name: Build and Push Docker image
301-
uses: docker/build-push-action@v5
302-
with:
303-
context: .
304-
push: true
305-
platforms: linux/amd64
306-
file: ${{ matrix.dockerfile }}
307-
tags: registry.digitalocean.com/ship-demo/ship-demo-${{ matrix.app_name }}:${{ github.sha }}
308-
target: runner
309-
cache-from: type=gha
310-
cache-to: type=gha,mode=max
311-
```
312-
313-
**WEB Build and Push Docker Image GH Action:**
314-
```yaml
315-
name: Build and Push Staging Web Image to DigitalOcean
316-
317-
on:
318-
push:
319-
branches: [main]
320-
paths:
321-
- "apps/web/**"
322-
- "packages/**"
323-
workflow_dispatch:
324-
325-
permissions:
326-
contents: read
327-
packages: write
328-
329-
jobs:
330-
build:
331-
name: Build and Push Docker Images
332-
runs-on: ubuntu-latest
333-
steps:
334-
- name: Checkout code
335-
uses: actions/checkout@v4
336-
337-
- name: Set up QEMU
338-
uses: docker/setup-qemu-action@v3
339-
340-
- name: Set up Docker Buildx
341-
uses: docker/setup-buildx-action@v3
342-
343-
- name: Login to Docker Hub
344-
uses: docker/login-action@v3
345-
with:
346-
registry: registry.digitalocean.com
347-
username: ${{ secrets.DO_USERNAME }}
348-
password: ${{ secrets.DO_ACCESS_TOKEN }}
349-
350-
- name: Build and Push Docker image
351-
uses: docker/build-push-action@v5
352-
with:
353-
context: .
354-
push: true
355-
platforms: linux/amd64
356-
file: ./apps/web/Dockerfile
357-
tags: registry.digitalocean.com/ship-demo/ship-demo-web:${{ github.sha }}
358-
target: runner
359-
cache-from: type=gha
360-
cache-to: type=gha,mode=max
361-
362-
```
363-
364-
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-
![Create new github secrets for DO container registry](/images/do-registry-github-secrets.png)
367-
368-
![Run and Build Docker images result](/images/run-build-and-push-do-image-results.png)
369-
370-
4. Navigate to your DigitalOcean Container Registry. You should see 4 newly added repositories, as shown in the screenshot below.
371-
372-
![Pushed Docker Images in DOCR](/images/pushed-images-in-docr.png)
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-
![API spec for DOCR](/images/api-app-spec-for-docr-deployment.png)
388-
389-
![Migrator spec for DOCR](/images/migrator-app-spec-for-docr-deployment.png)
390-
391-
![Scheduler spec for DOCR](/images/scheduler-app-spec-for-docr-deployment.png)
392-
393-
7. Do the same actions for web app.
394-
395-
![WEB spec for DOCR](/images/web-app-spec-for-docr-deployment.png)
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`.
398-
399-
**New API deployment github action:**
400-
```yaml
401-
name: "Staging application API deployment"
402-
403-
on:
404-
push:
405-
branches: [main]
406-
paths:
407-
- "apps/api/**"
408-
- "packages/**"
409-
workflow_dispatch:
410-
inputs:
411-
logLevel:
412-
description: "Log level"
413-
required: true
414-
default: "warning"
415-
tags:
416-
description: "Test scenario"
417-
required: false
418-
419-
permissions:
420-
contents: read
421-
packages: write
422-
423-
jobs:
424-
build:
425-
name: Build and Push Docker Images
426-
runs-on: ubuntu-latest
427-
strategy:
428-
matrix:
429-
include:
430-
- app_name: api
431-
dockerfile: apps/api/Dockerfile
432-
- app_name: migrator
433-
dockerfile: apps/api/Dockerfile.migrator
434-
- app_name: scheduler
435-
dockerfile: apps/api/Dockerfile.scheduler
436-
steps:
437-
- name: Checkout code
438-
uses: actions/checkout@v4
439-
440-
- name: Set up QEMU
441-
uses: docker/setup-qemu-action@v3
442-
443-
- name: Set up Docker Buildx
444-
uses: docker/setup-buildx-action@v3
445-
446-
- name: Login to Docker Hub
447-
uses: docker/login-action@v3
448-
with:
449-
registry: registry.digitalocean.com
450-
username: ${{ secrets.DO_USERNAME }}
451-
password: ${{ secrets.DO_ACCESS_TOKEN }}
452-
453-
- name: Build and Push Docker image
454-
uses: docker/build-push-action@v5
455-
with:
456-
context: .
457-
push: true
458-
platforms: linux/amd64
459-
file: ${{ matrix.dockerfile }}
460-
tags: registry.digitalocean.com/ship-demo/ship-demo-${{ matrix.app_name }}:${{ github.sha }}
461-
target: runner
462-
cache-from: type=gha
463-
cache-to: type=gha,mode=max
464-
465-
deploy:
466-
name: Deploy to DigitalOcean
467-
runs-on: ubuntu-latest
468-
needs: build
469-
steps:
470-
- name: Deploy to DigitalOcean App Platform
471-
uses: digitalocean/app_action/deploy@v2
472-
env:
473-
IMAGE_TAG_SHIP_DEMO_API: ${{ github.sha }}
474-
IMAGE_TAG_SHIP_DEMO_MIGRATOR: ${{ github.sha }}
475-
IMAGE_TAG_SHIP_DEMO_SCHEDULER: ${{ github.sha }}
476-
with:
477-
token: ${{ secrets.DO_ACCESS_TOKEN }}
478-
app_name: ${{ secrets.DO_API_STAGING_APP_NAME }}
479-
```
480-
481-
**New WEB deployment github action:**
482-
```yaml
483-
name: "Staging application Web deployment"
484-
485-
on:
486-
push:
487-
branches: [main]
488-
paths:
489-
- "apps/web/**"
490-
- "packages/**"
491-
workflow_dispatch:
492-
inputs:
493-
logLevel:
494-
description: "Log level"
495-
required: true
496-
default: "warning"
497-
tags:
498-
description: "Test scenario"
499-
required: false
500-
501-
jobs:
502-
build:
503-
name: Build and Push Docker Images
504-
runs-on: ubuntu-latest
505-
steps:
506-
- name: Checkout code
507-
uses: actions/checkout@v4
508-
509-
- name: Set up QEMU
510-
uses: docker/setup-qemu-action@v3
511-
512-
- name: Set up Docker Buildx
513-
uses: docker/setup-buildx-action@v3
514-
515-
- name: Login to Docker Hub
516-
uses: docker/login-action@v3
517-
with:
518-
registry: registry.digitalocean.com
519-
username: ${{ secrets.DO_USERNAME }}
520-
password: ${{ secrets.DO_ACCESS_TOKEN }}
521-
522-
- name: Build and Push Docker image
523-
uses: docker/build-push-action@v5
524-
with:
525-
context: .
526-
push: true
527-
platforms: linux/amd64
528-
file: ./apps/web/Dockerfile
529-
tags: registry.digitalocean.com/ship-demo/ship-demo-web:${{ github.sha }}
530-
target: runner
531-
cache-from: type=gha
532-
cache-to: type=gha,mode=max
533-
build-args: |
534-
APP_ENV=staging
535-
536-
deploy:
537-
name: Deploy to DigitalOcean
538-
runs-on: ubuntu-latest
539-
needs: build
540-
steps:
541-
- name: Deploy to DigitalOcean App Platform
542-
uses: digitalocean/app_action/deploy@v2
543-
env:
544-
IMAGE_TAG_SHIP_DEMO_WEB: ${{ github.sha }}
545-
with:
546-
token: ${{ secrets.DO_ACCESS_TOKEN }}
547-
app_name: ${{ secrets.DO_WEB_STAGING_APP_NAME }}
548-
```
549-
550-
<Note>
551-
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.
555-
556-
![Deploy actions compressions](/images/deploy-actions-compressions.png)
243+
<GithubActionsWithPrebuiltImagesSnippet/>
557244

558245
## Set up migrator and scheduler (Optional)
559246

0 commit comments

Comments
 (0)