Skip to content

Commit

Permalink
refactor: deploy with gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
RRRHAN committed Mar 2, 2024
1 parent 00b5063 commit 000d53a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 33 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy to Cloud Run

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Install fe dependencies
run: yarn install
working-directory: ./front-end
- name: Build fe
run: yarn run build
working-directory: ./front-end
env:
REACT_APP_FOO: bar
REACT_APP_BASE_URL: /api/
- name: inject fe
run: mkdir "./back-end/ui" && cp -R "./front-end/build/"* "./back-end/ui"
- uses: actions/checkout@v2
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '333.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- run: |
gcloud auth configure-docker
gcloud components install beta
working-directory: ./back-end
- run: docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-app-name .
working-directory: ./back-end
- run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-app-name
working-directory: ./back-end
- run: gcloud beta run deploy your-app-name --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-app-name --platform managed --region your-region
working-directory: ./back-end
env:
GOOGLE_CLOUD_PROJECT: ${{ secrets.GCP_PROJECT_ID }}
33 changes: 0 additions & 33 deletions .github/workflows/fly.yml

This file was deleted.

30 changes: 30 additions & 0 deletions back-end/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use the official Golang image
FROM golang:1.20-alpine as builder

WORKDIR /app

# Copy the Go modules files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy the source code into the container
COPY . .

# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -o app .

# Final image
FROM alpine:latest

WORKDIR /root/

# Copy the binary from the builder stage
COPY --from=builder /app/app .

# Expose port 8080
EXPOSE 9999

# Command to run the app
CMD ["./app"]

0 comments on commit 000d53a

Please sign in to comment.