Skip to content

Commit

Permalink
Merge pull request #1 from growthbook/ji/add-dockerfile-and-deploy-yml
Browse files Browse the repository at this point in the history
Add Dockerfile and deploy.yml
  • Loading branch information
tzjames authored Jun 26, 2024
2 parents eb1ac09 + 837c9c7 commit 0cec9c9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy

on:
# Push to the main branch
push:
branches:
- main
jobs:
# Build and publish the commit to docker
docker:
runs-on: ubuntu-latest
if: ${{ github.repository == 'growthbook/smokescreen' }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Install Depot CLI
uses: depot/setup-action@v1

- name: Prepare build metadata
id: metadata
run: |
# Store current git hash and date in files
mkdir -p buildinfo
echo "${GITHUB_SHA}" > buildinfo/SHA
printf '%(%Y-%m-%dT%H:%M:%SZ)T' > buildinfo/DATE
echo "sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Build, tag, and push image to Docker Hub
uses: depot/build-push-action@v1
with:
push: true
context: .
project: vmp2ssvj9r
tags: |
growthbook/smokescreen:latest
growthbook/smokescreen:git-${{ steps.metadata.outputs.sha }}
platforms: linux/amd64

# Deploy Smokescreen to AWS ECS
prod:
runs-on: ubuntu-latest
needs: [docker]
if: ${{ github.repository == 'growthbook/smokescreen' }}
steps:
- name: Configure AWS credentials for GrowthBook Cloud
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Deploy docker image to ECS for GrowthBook Cloud API
run: aws ecs update-service --cluster prod-smokescreen --service prod-smokescreen --force-new-deployment --region us-east-1
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang as builder

WORKDIR /go/src/app
COPY . .

RUN go build -o smokescreen .

FROM alpine:3.20.1

COPY --from=builder /go/src/app/smokescreen /usr/local/bin/smokescreen

RUN apk add --no-cache gcompat

EXPOSE 4750

CMD ["smokescreen"]

0 comments on commit 0cec9c9

Please sign in to comment.