-
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.
- Loading branch information
Showing
5 changed files
with
116 additions
and
1 deletion.
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,6 @@ | ||
.git | ||
**/node_modules | ||
**/build | ||
**/dist | ||
**/terraform | ||
**/tf |
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,70 @@ | ||
name: STAGING - Deploy API | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- "deploy-staging/**" | ||
paths: | ||
- apps/api/** | ||
- .github/workflows/deploy-api-staging.yml | ||
|
||
jobs: | ||
build-api: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: staging | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1-node16 | ||
with: | ||
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.STAGING_AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ secrets.STAGING_AWS_ECR_REGISTRY }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -f ./Dockerfile --build-arg VERSION=$IMAGE_TAG -t $ECR_REGISTRY:$IMAGE_TAG . | ||
docker tag $ECR_REGISTRY:$IMAGE_TAG $ECR_REGISTRY:latest | ||
docker push $ECR_REGISTRY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY:latest | ||
- name: Install Selleo CLI | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: selleo/cli | ||
tag: v0.26.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: ECS Deployment | ||
env: | ||
AWS_REGION: ${{ secrets.STAGING_AWS_REGION }} | ||
ECS_CLUSTER: ${{ vars.STAGING_ECS_CLUSTER }} | ||
ECS_SERVICE: ${{ vars.STAGING_ECS_SERVICE }} | ||
DOCKER_IMAGE: ${{ secrets.STAGING_AWS_ECR_REGISTRY }}:${{ github.sha }} | ||
run: selleo aws ecs deploy --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --docker-image $DOCKER_IMAGE --one-off migrate | ||
|
||
- name: ECS Run migrations | ||
env: | ||
AWS_REGION: ${{ secrets.STAGING_AWS_REGION }} | ||
ECS_CLUSTER: ${{ vars.STAGING_ECS_CLUSTER }} | ||
ECS_SERVICE: ${{ vars.STAGING_ECS_SERVICE }} | ||
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off migrate | ||
|
||
- name: ECS Run seeds | ||
env: | ||
AWS_REGION: ${{ secrets.STAGING_AWS_REGION }} | ||
ECS_CLUSTER: ${{ vars.STAGING_ECS_CLUSTER }} | ||
ECS_SERVICE: ${{ vars.STAGING_ECS_SERVICE }} | ||
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off seed |
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,21 @@ | ||
FROM node:20.15.0-alpine AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install | ||
RUN pnpm build --filter=api | ||
# TODO: Move pnpm deploy to turbo prune workflow | ||
RUN pnpm deploy --filter=api pnpm-deploy-output --prod | ||
|
||
FROM node:20.15.0-alpine | ||
WORKDIR /app | ||
COPY --from=base /app/pnpm-deploy-output /app | ||
|
||
RUN chmod +x /app/entrypoint.sh | ||
|
||
ENTRYPOINT [ "/app/entrypoint.sh" ] |
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,18 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
COMMAND="${1:-server}" | ||
|
||
if [ $COMMAND = "server" ]; then | ||
echo "Starting server..." | ||
npm run start:prod | ||
elif [ $COMMAND = "migrate" ]; then | ||
echo "Running migrations..." | ||
npm run db:migrate | ||
elif [ $COMMAND = "seed" ]; then | ||
echo "Running seeds..." | ||
node /app/dist/bin/seed.js | ||
else | ||
echo "Usage: entrypoint.sh [server|migrate]" | ||
exit 1 | ||
fi |
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