forked from stripe/smokescreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from growthbook/ji/add-dockerfile-and-deploy-yml
Add Dockerfile and deploy.yml
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |