Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connects to #130. Continuous delivery pipeline using Cloud Build. #131

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
node_modules
build
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# create-react-app build environment
FROM node:16-alpine as react-build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package*.json ./
RUN yarn
COPY . ./
RUN yarn sass
RUN yarn build

# nginx server environment
FROM nginx:stable-alpine
COPY nginx.conf /etc/nginx/conf.d/configfile.template
ENV PORT 80
ENV HOST 0.0.0.0
RUN sh -c "envsubst '\$PORT' < /etc/nginx/conf.d/configfile.template > /etc/nginx/conf.d/default.conf"
COPY --from=react-build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
40 changes: 40 additions & 0 deletions builder/cloudbuild-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
steps:
#Build the image
- name: 'gcr.io/cloud-builders/docker'
env:
- 'DISABLE_ESLINT_PLUGIN=true'
- 'REACT_APP_ES_PROXY_HOST=$_REACT_APP_ES_PROXY_HOST'
- 'REACT_APP_ES_PROXY_HOST_DEV=$_REACT_APP_ES_PROXY_HOST_DEV'
- 'REACT_APP_API_SERVICE_ADDRESS=$_REACT_APP_API_SERVICE_ADDRESS'
- 'REACT_APP_API_SERVICE_ADDRESS_DEV=$_REACT_APP_API_SERVICE_ADDRESS_DEV'
- 'REACT_APP_API_SERVICE_KEY=$_REACT_APP_API_SERVICE_KEY'
- 'REACT_APP_API_SERVICE_KEY_DEV=$_REACT_APP_API_SERVICE_KEY_DEV'
- 'REACT_APP_SIGNED_URL_ENDPOINT=$_REACT_APP_SIGNED_URL_ENDPOINT'
- 'REACT_APP_USER_REGISTRATION_ENDPOINT=$_REACT_APP_USER_REGISTRATION_ENDPOINT'
- 'REACT_APP_SEND_EMAIL_ENDPOINT=$_REACT_APP_SEND_EMAIL_ENDPOINT'
- 'REACT_APP_FILE_DOWNLOAD_ENDPOINT=$_REACT_APP_FILE_DOWNLOAD_ENDPOINT'
- 'REACT_APP_QC_DATA_ENDPOINT=$_REACT_APP_QC_DATA_ENDPOINT'
- 'REACT_APP_ES_ENDPOINT=$_REACT_APP_ES_ENDPOINT'
- 'REACT_APP_FILE_SEARCH_ENDPOINT=$_REACT_APP_FILE_SEARCH_ENDPOINT'
- 'REACT_APP_DATA_FILE_BUCKET=$_REACT_APP_DATA_FILE_BUCKET'
- 'REACT_APP_QC_REPORT_BUCKET=$_REACT_APP_QC_REPORT_BUCKET'
- 'REACT_APP_QC_REPORT_BUCKET_DEV=$_REACT_APP_QC_REPORT_BUCKET_DEV'
- 'REACT_APP_ES_ACCESS_TOKEN=$_REACT_APP_ES_ACCESS_TOKEN'
- 'REACT_APP_ES_ACCESS_TOKEN_DEV=$_REACT_APP_ES_ACCESS_TOKEN_DEV'
- 'REACT_APP_reCAPTCHA_SITE_KEY=$_REACT_APP_RECAPTCHA_SITE_KEY'
- 'REACT_APP_AUTH0_CLIENT_ID=$_REACT_APP_AUTH0_CLIENT_ID'
script: 'echo $DISABLE_ESLINT_PLUGIN && echo $REACT_APP_ES_PROXY_HOST && echo $REACT_APP_ES_PROXY_HOST_DEV && echo $REACT_APP_API_SERVICE_ADDRESS && echo $REACT_APP_API_SERVICE_ADDRESS_DEV && echo $REACT_APP_API_SERVICE_KEY && echo $REACT_APP_API_SERVICE_KEY_DEV && echo $REACT_APP_SIGNED_URL_ENDPOINT && echo $REACT_APP_USER_REGISTRATION_ENDPOINT && echo $REACT_APP_SEND_EMAIL_ENDPOINT && echo $REACT_APP_FILE_DOWNLOAD_ENDPOINT && echo $REACT_APP_QC_DATA_ENDPOINT && echo $REACT_APP_ES_ENDPOINT && echo $REACT_APP_FILE_SEARCH_ENDPOINT && echo $REACT_APP_DATA_FILE_BUCKET && echo $REACT_APP_QC_REPORT_BUCKET && echo $REACT_APP_QC_REPORT_BUCKET_DEV && echo $REACT_APP_ES_ACCESS_TOKEN && echo $REACT_APP_ES_ACCESS_TOKEN_DEV && echo $REACT_APP_reCAPTCHA_SITE_KEY && echo $REACT_APP_AUTH0_CLIENT_ID'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/motrpac-frontend-dev:$SHORT_SHA', '.']

#Push the image
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/motrpac-frontend-dev:$SHORT_SHA']

# deploy container image to GKE
- name: "gcr.io/cloud-builders/gke-deploy"
args:
- run
- --filename=kubernetes/dev/
- --image=gcr.io/$PROJECT_ID/motrpac-frontend-dev:$SHORT_SHA
- --location=us-west1-a
- --cluster=motrpac-frontend-dev-cluster
17 changes: 17 additions & 0 deletions builder/cloudbuild-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
steps:
#Build the image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/motrpac-frontend-prod:$TAG_NAME', '.']

#Push the image
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/motrpac-frontend-prod:$TAG_NAME']

# deploy container image to GKE
- name: "gcr.io/cloud-builders/gke-deploy"
args:
- run
- --filename=kubernetes/prod/
- --image=gcr.io/$PROJECT_ID/motrpac-frontend-prod:$TAG_NAME
- --location=us-west1-a
- --cluster=motrpac-frontend-prod-cluster
17 changes: 17 additions & 0 deletions builder/cloudbuild-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
steps:
#Build the image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/motrpac-frontend-staging:$SHORT_SHA', '.']

#Push the image
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/motrpac-frontend-staging:$SHORT_SHA']

# deploy container image to GKE
- name: "gcr.io/cloud-builders/gke-deploy"
args:
- run
- --filename=kubernetes/staging/
- --image=gcr.io/$PROJECT_ID/motrpac-frontend-staging:$SHORT_SHA
- --location=us-west1-a
- --cluster=motrpac-frontend-staging-cluster
24 changes: 24 additions & 0 deletions kubernetes/dev/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: motrpac-frontend-dev
namespace: motrpac-portal-dev
labels:
app: motrpac-frontend
spec:
replicas: 1
selector:
matchLabels:
app: motrpac-frontend
env: dev
template:
metadata:
labels:
app: motrpac-frontend
env: dev
spec:
containers:
- name: motrpac-frontend-app
image: gcr.io/motrpac-portal-dev/motrpac-frontend-dev:v1
ports:
- containerPort: 80
4 changes: 4 additions & 0 deletions kubernetes/dev/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: "v1"
kind: "Namespace"
metadata:
name: "motrpac-portal-dev"
11 changes: 11 additions & 0 deletions kubernetes/dev/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: motrpac-frontend-dev
spec:
type: LoadBalancer
selector:
app: motrpac-frontend
ports:
- port: 80
targetPort: 80
24 changes: 24 additions & 0 deletions kubernetes/prod/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: motrpac-frontend-prod
namespace: motrpac-portal-prod
labels:
app: motrpac-frontend
spec:
replicas: 2
selector:
matchLabels:
app: motrpac-frontend
env: production
template:
metadata:
labels:
app: motrpac-frontend
env: production
spec:
containers:
- name: motrpac-frontend-app
image: gcr.io/motrpac-portal-dev/motrpac-frontend-prod:v1
ports:
- containerPort: 80
11 changes: 11 additions & 0 deletions kubernetes/prod/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: motrpac-frontend-prod
spec:
type: LoadBalancer
selector:
app: motrpac-frontend
ports:
- port: 80
targetPort: 80
24 changes: 24 additions & 0 deletions kubernetes/staging/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: motrpac-frontend-staging
namespace: motrpac-portal-staging
labels:
app: motrpac-frontend
spec:
replicas: 1
selector:
matchLabels:
app: motrpac-frontend
env: staging
template:
metadata:
labels:
app: motrpac-frontend
env: staging
spec:
containers:
- name: motrpac-frontend-app
image: gcr.io/motrpac-portal-dev/motrpac-frontend-staging:v1
ports:
- containerPort: 80
11 changes: 11 additions & 0 deletions kubernetes/staging/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: motrpac-frontend-staging
spec:
type: LoadBalancer
selector:
app: motrpac-frontend
ports:
- port: 80
targetPort: 80
18 changes: 18 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen $PORT;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "DISABLE_ESLINT_PLUGIN='true' react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009 -s public",
Expand Down