-
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
3 changed files
with
77 additions
and
33 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,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 }} |
This file was deleted.
Oops, something went wrong.
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,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"] |