Skip to content

Commit

Permalink
feat: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Firgrep committed May 21, 2024
1 parent eed1850 commit 00e7705
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci-cd-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: stripe-warden CI/CD DEV

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build-and-deploy:
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
SERVICE: ${{ secrets.GCP_SERVICE }}
REGION: ${{ secrets.GCP_REGION }}
TAG: latest
runs-on: ubuntu-latest
environment: development
steps:
# checkout the repo
- name: "Checkout GitHub Action"
uses: actions/checkout@master

# Authenticate to Google Cloud
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}"

# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
id: docker-auth
uses: "docker/login-action@v3"
with:
username: _json_key
password: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}"
registry: "${{ env.REGION }}-docker.pkg.dev"

# Build and push the Docker image
- name: Build and Push Container
run: |-
cd packages/stripe-warden &&
docker build \
-f Dockerfile \
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" .
echo "=== IMAGE NAME: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}"
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}"
# Deploy to Cloud Run
- name: Deploy to Cloud Run
run: |
gcloud run deploy ${{ env.SERVICE }} \
--platform=managed \
--port=3000 \
--region=${{ env.REGION }} \
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" \
--min-instances=0 \
--max-instances=1
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM oven/bun:latest as base
WORKDIR /usr/src/app

COPY . .
RUN bun install

ENV NODE_ENV=production
ENV PORT=3000

RUN chown -R bun:bun ./

USER bun
EXPOSE 3000/tcp
CMD [ "bun", "run", "src/index.ts" ]
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ app.get("/:id/:filename", async (req: Request, res: Response) => {
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});

// http://localhost:3000/cluvqhyly0007uwfdmg2hn33a/VID_20200103_135115.mp4

0 comments on commit 00e7705

Please sign in to comment.