From d45671b64e1f8755b536c90f424c3481da4038c7 Mon Sep 17 00:00:00 2001 From: Marcus Kohlberg Date: Tue, 7 Jan 2025 16:50:24 +0100 Subject: [PATCH 1/2] cicd docs --- docs/go/self-host/ci-cd.md | 41 ++++++++++++++++++++++++++++++++++++++ docs/menu.cue | 12 +++++++++++ docs/ts/self-host/ci-cd.md | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 docs/go/self-host/ci-cd.md create mode 100644 docs/ts/self-host/ci-cd.md diff --git a/docs/go/self-host/ci-cd.md b/docs/go/self-host/ci-cd.md new file mode 100644 index 0000000000..8c69c474bb --- /dev/null +++ b/docs/go/self-host/ci-cd.md @@ -0,0 +1,41 @@ +--- +seotitle: Integrate with your CI/CD pipeline +seodesc: Learn how to integrate Encore.go with your CI/CD pipeline. +title: Integrate with your CI/CD pipeline +lang: go +--- + +Encore seamlessly integrates with any CI/CD pipeline through its CLI tools. You can automate Docker image creation using the `encore build` command as part of your deployment workflow. + +## Integrating with CI/CD Platforms + +While every CI/CD pipeline is unique, integrating Encore follows a straightforward process. Here are the key steps: + +1. Install the Encore CLI in your CI environment +2. Use `encore build docker` to create Docker images +3. Push the images to your container registry +4. Deploy to your infrastructure + +Refer to your CI/CD platform's documentation for more details on how to integrate CLI tools like `encore build`. + +## Building Docker Images + +The `encore build docker` command provides several options to customize your builds: + +```bash +# Build specific services and gateways +encore build docker --services=service1,service2 --gateways=api-gateway MY-IMAGE:TAG + +# Customize the base image +encore build docker --base=node:18-alpine MY-IMAGE:TAG +``` + +The image will default to run on port 8080, but you can customize it by setting the `PORT` environment variable when starting your image. + +```bash +docker run -e PORT=8081 -p 8081:8081 MY-IMAGE:TAG +``` + +Learn more about the `encore build docker` command in the [build Docker images](/docs/go/self-host/docker-build) guide. + +Continue to learn how to [configure infrastructure](/docs/go/self-host/configure-infra). diff --git a/docs/menu.cue b/docs/menu.cue index 45bad9a6d3..930f435128 100644 --- a/docs/menu.cue +++ b/docs/menu.cue @@ -441,6 +441,12 @@ kind: "section" text: "Self Hosting" items: [ + { + kind: "basic" + text: "CI/CD" + path: "/go/self-host/ci-cd" + file: "go/self-host/ci-cd" + }, { kind: "basic" text: "Build Docker Images" @@ -888,6 +894,12 @@ kind: "section" text: "Self Hosting" items: [ + { + kind: "basic" + text: "CI/CD" + path: "/ts/self-host/ci-cd" + file: "ts/self-host/ci-cd" + }, { kind: "basic" text: "Build Docker Images" diff --git a/docs/ts/self-host/ci-cd.md b/docs/ts/self-host/ci-cd.md new file mode 100644 index 0000000000..6cb2888d48 --- /dev/null +++ b/docs/ts/self-host/ci-cd.md @@ -0,0 +1,41 @@ +--- +seotitle: Integrate with your CI/CD pipeline +seodesc: Learn how to integrate Encore.ts with your CI/CD pipeline. +title: Integrate with your CI/CD pipeline +lang: ts +--- + +Encore seamlessly integrates with any CI/CD pipeline through its CLI tools. You can automate Docker image creation using the `encore build` command as part of your deployment workflow. + +## Integrating with CI/CD Platforms + +While every CI/CD pipeline is unique, integrating Encore follows a straightforward process. Here are the key steps: + +1. Install the Encore CLI in your CI environment +2. Use `encore build docker` to create Docker images +3. Push the images to your container registry +4. Deploy to your infrastructure + +Refer to your CI/CD platform's documentation for more details on how to integrate CLI tools like `encore build`. + +## Building Docker Images + +The `encore build docker` command provides several options to customize your builds: + +```bash +# Build specific services and gateways +encore build docker --services=service1,service2 --gateways=api-gateway MY-IMAGE:TAG + +# Customize the base image +encore build docker --base=node:18-alpine MY-IMAGE:TAG +``` + +The image will default to run on port 8080, but you can customize it by setting the `PORT` environment variable when starting your image. + +```bash +docker run -e PORT=8081 -p 8081:8081 MY-IMAGE:TAG +``` + +Learn more about the `encore build docker` command in the [build Docker images](/docs/ts/self-host/build) guide. + +Continue to learn how to [configure infrastructure](/docs/ts/self-host/configure-infra). From d6146b42c03c4b8ad8a93a1a7cf41668839c396b Mon Sep 17 00:00:00 2001 From: Simon Johansson Date: Wed, 8 Jan 2025 09:48:43 +0100 Subject: [PATCH 2/2] Add GitHub actions example --- docs/go/self-host/ci-cd.md | 44 ++++++++++++++++++++++++++++++++++++++ docs/ts/self-host/ci-cd.md | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/docs/go/self-host/ci-cd.md b/docs/go/self-host/ci-cd.md index 8c69c474bb..f961e3ec5e 100644 --- a/docs/go/self-host/ci-cd.md +++ b/docs/go/self-host/ci-cd.md @@ -18,6 +18,50 @@ While every CI/CD pipeline is unique, integrating Encore follows a straightforwa Refer to your CI/CD platform's documentation for more details on how to integrate CLI tools like `encore build`. +### GitHub actions example + +This example shows how to build, push, and deploy an Encore Docker image to DigitalOcean using GitHub Actions. +The DigitalOcean application is set up re-deploy the application every time an image with the tag `latest` is uploaded. + +```yaml +name: Build, Push and Deploy a Encore Docker Image to DigitalOcean + +on: + push: + branches: [ main ] + +permissions: + contents: read + packages: write + +jobs: + build-push-deploy-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download Encore CLI script + uses: sozo-design/curl@v1.0.2 + with: + args: --output install.sh -L https://encore.dev/install.sh + + - name: Install Encore CLI + run: bash install.sh + + - name: Log in to DigitalOcean container registry + run: docker login registry.digitalocean.com -u my-email@gmail.com -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Build Docker image + run: /home/runner/.encore/bin/encore build docker myapp + + - name: Tag Docker image + run: docker tag myapp registry.digitalocean.com//:latest + + - name: Push Docker image + run: docker push registry.digitalocean.com//:latest +``` + ## Building Docker Images The `encore build docker` command provides several options to customize your builds: diff --git a/docs/ts/self-host/ci-cd.md b/docs/ts/self-host/ci-cd.md index 6cb2888d48..9b1e459a66 100644 --- a/docs/ts/self-host/ci-cd.md +++ b/docs/ts/self-host/ci-cd.md @@ -18,6 +18,50 @@ While every CI/CD pipeline is unique, integrating Encore follows a straightforwa Refer to your CI/CD platform's documentation for more details on how to integrate CLI tools like `encore build`. +### GitHub actions example + +This example shows how to build, push, and deploy an Encore Docker image to DigitalOcean using GitHub Actions. +The DigitalOcean application is set up re-deploy the application every time an image with the tag `latest` is uploaded. + +```yaml +name: Build, Push and Deploy a Encore Docker Image to DigitalOcean + +on: + push: + branches: [ main ] + +permissions: + contents: read + packages: write + +jobs: + build-push-deploy-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download Encore CLI script + uses: sozo-design/curl@v1.0.2 + with: + args: --output install.sh -L https://encore.dev/install.sh + + - name: Install Encore CLI + run: bash install.sh + + - name: Log in to DigitalOcean container registry + run: docker login registry.digitalocean.com -u my-email@gmail.com -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Build Docker image + run: /home/runner/.encore/bin/encore build docker myapp + + - name: Tag Docker image + run: docker tag myapp registry.digitalocean.com//:latest + + - name: Push Docker image + run: docker push registry.digitalocean.com//:latest +``` + ## Building Docker Images The `encore build docker` command provides several options to customize your builds: