Skip to content

Commit

Permalink
Merge pull request #15 from Mexidense/feat/add-google-cloud-ci-cd
Browse files Browse the repository at this point in the history
chore: set Google Cloud RUN as CI/CD
  • Loading branch information
Mexidense authored Dec 12, 2023
2 parents 8431264 + d2c70cf commit fe14dd3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
47 changes: 47 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and deploy UML2Code with Google Cloud Run

on:
push:
branches:
- main

env:
CLOUD_RUN_PROJECT_ID: ${{ secrets.CLOUD_RUN_PROJECT_NAME }}
CLOUD_RUN_REGION: europe-southwest1
REPO_NAME: uml2code

jobs:
build-and-deploy:
name: Setup, Build, and Deploy
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- uses: google-github-actions/setup-gcloud@v0.2.0
with:
project_id: ${{ secrets.CLOUD_RUN_PROJECT_NAME }}
service_account_key: ${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }}
service_account_email: ${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT_EMAIL }}

- name: Enable the necessary APIs and enable docker auth
run: |-
gcloud services enable containerregistry.googleapis.com
gcloud services enable run.googleapis.com
gcloud --quiet auth configure-docker
- name: Build and tag image
run: |-
docker build . --tag "gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA"
- name: Push image to GCR
run: |-
docker push gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA
- name: Deploy
run: |-
gcloud components install beta --quiet
gcloud beta run deploy $REPO_NAME --image gcr.io/$CLOUD_RUN_PROJECT_ID/$REPO_NAME:$GITHUB_SHA \
--project $CLOUD_RUN_PROJECT_ID \
--platform managed \
--region $CLOUD_RUN_REGION \
--allow-unauthenticated \
--quiet
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ ARG PUBLIC_APP_URL

FROM node:18.17.0-alpine
RUN mkdir /app
COPY package.json /app/
WORKDIR /app

COPY . ./
WORKDIR /app

ENV NEXT_PUBLIC_APP_URL ${PUBLIC_APP_URL}
COPY . .

RUN npm ci
RUN npm ci --omit=dev
RUN npm run build

EXPOSE 3000

CMD ["npm", "run","start"]
CMD ["npm", "start"]
11 changes: 10 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const path = require('path')

const nextConfig = {
output: 'standalone',
webpack: (config, { _isServer }) => {
config.resolve.alias['@uml2code'] = path.resolve(__dirname, './src/');

return config;
},
}

module.exports = nextConfig
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"start": "next start -p $PORT",
"lint": "next lint"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@uml2code/*": ["./src/*"]
}
Expand Down

0 comments on commit fe14dd3

Please sign in to comment.