From 988fc9a5dc7323feaad812d8d917c2f6f0f9fd05 Mon Sep 17 00:00:00 2001 From: Brennan Wilkes Date: Mon, 1 Feb 2021 10:29:13 -0800 Subject: [PATCH] feat: Initial CI/CD Beta Deploy --- .dockerignore | 4 +++- .gitlab-ci.yml | 19 +++++++++++++++++++ Dockerfile | 9 ++++----- package.json | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.dockerignore b/.dockerignore index 3a80671..07efc8e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ -# .dockerignore +Dockerfile +README.md node_modules +npm-debug.log diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..bc0eb58 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +default: + image: google/cloud-sdk:alpine + before_script: + - gcloud config set project $GOOGLE_CLOUD_PROJECT + - gcloud auth activate-service-account --key-file $GOOGLE_CLOUD_CREDENTIALS + +build-beta: + stage: build-beta + script: + - gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/gcs-radio-beta + only: + - beta + +deploy-beta: + stage: deploy-beta + script: + - gcloud run deploy gcs-radio-beta --image gcr.io/$GOOGLE_CLOUD_PROJECT/gcs-radio-beta --platform managed --region us-west1 --allow-unauthenticated + only: + - beta diff --git a/Dockerfile b/Dockerfile index 34ef99d..b5b7090 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,18 @@ -# Use the official lightweight Node.js 12 image. -# https://hub.docker.com/_/node FROM node:12-alpine -# Create and change to the app directory. WORKDIR /usr/src/app -# Copy application dependency manifests to the container image. # Copying this separately prevents re-running npm install on every code change. COPY package*.json ./ # Install production dependencies. -RUN npm install --only=production +RUN npm install # Copy local code to the container image. COPY . ./ +RUN npm run build +RUN npm prune --production + # Run the web service on container startup. CMD [ "npm", "start" ] diff --git a/package.json b/package.json index d226c77..0a2fa1d 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "clean": "rimraf build", "rebuild": "npm run build", "prerebuild": "npm run clean", + "prebuild": "npm run lint", "test": "jest --colors --verbose", "lint": "eslint \"src/**/*.[jt]s\" --fix" },