Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cicd docs #1687

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/go/self-host/ci-cd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
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`.

### 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/[email protected]
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 [email protected] -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/<YOUR_CONTAINER_REGISTRY_NAME>/<YOUR_IMAGE_REPOSITORY_NAME>:latest

- name: Push Docker image
run: docker push registry.digitalocean.com/<YOUR_CONTAINER_REGISTRY_NAME>/<YOUR_IMAGE_REPOSITORY_NAME>:latest
```

## 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).
12 changes: 12 additions & 0 deletions docs/menu.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
85 changes: 85 additions & 0 deletions docs/ts/self-host/ci-cd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
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`.

### 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/[email protected]
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 [email protected] -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/<YOUR_CONTAINER_REGISTRY_NAME>/<YOUR_IMAGE_REPOSITORY_NAME>:latest

- name: Push Docker image
run: docker push registry.digitalocean.com/<YOUR_CONTAINER_REGISTRY_NAME>/<YOUR_IMAGE_REPOSITORY_NAME>:latest
```

## 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).
Loading