Skip to content

Commit

Permalink
build: add dev Dockerfile and update CD action
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirsamdarshi committed May 1, 2024
1 parent 886e2f4 commit 127593b
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 13 deletions.
61 changes: 49 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,60 @@ jobs:
run: |
echo "PACKAGE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- name: Select project based on base branch
id: select-project
run: |
if [[ ${{ github.ref }} == 'refs/heads/master' ]]; then
echo "PROJECT_ID=motrpac-portal" >> $GITHUB_ENV
else
echo "PROJECT_ID=motrpac-portal-dev" >> $GITHUB_ENV
fi
- name: Build and push server image (prod)
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
tags: |
us-docker.pkg.dev/motrpac-portal/datahub/frontend:${{ github.sha }}
us-docker.pkg.dev/motrpac-portal/datahub/frontend:${{ env.PACKAGE_VERSION }}
us-docker.pkg.dev/motrpac-portal/datahub/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
REACT_APP_ES_PROXY_HOST="${{secrets.REACT_APP_ES_PROXY_HOST}}"
REACT_APP_ES_PROXY_HOST_DEV="${{secrets.REACT_APP_ES_PROXY_HOST_DEV}}"
REACT_APP_API_SERVICE_ADDRESS="${{secrets.REACT_APP_API_SERVICE_ADDRESS}}"
REACT_APP_API_SERVICE_ADDRESS_DEV="${{secrets.REACT_APP_API_SERVICE_ADDRESS_DEV}}"
REACT_APP_API_SERVICE_KEY="${{secrets.REACT_APP_API_SERVICE_KEY}}"
REACT_APP_API_SERVICE_KEY_DEV="${{secrets.REACT_APP_API_SERVICE_KEY_DEV}}"
REACT_APP_SIGNED_URL_ENDPOINT="${{secrets.REACT_APP_SIGNED_URL_ENDPOINT}}"
REACT_APP_USER_REGISTRATION_ENDPOINT="${{secrets.REACT_APP_USER_REGISTRATION_ENDPOINT}}"
REACT_APP_SEND_EMAIL_ENDPOINT="${{secrets.REACT_APP_SEND_EMAIL_ENDPOINT}}"
REACT_APP_FILE_DOWNLOAD_ENDPOINT="${{secrets.REACT_APP_FILE_DOWNLOAD_ENDPOINT}}"
REACT_APP_QC_DATA_ENDPOINT="${{secrets.REACT_APP_QC_DATA_ENDPOINT}}"
REACT_APP_ES_ENDPOINT="${{secrets.REACT_APP_ES_ENDPOINT}}"
REACT_APP_FILE_SEARCH_ENDPOINT="${{secrets.REACT_APP_FILE_SEARCH_ENDPOINT}}"
REACT_APP_DATA_FILE_BUCKET="${{secrets.REACT_APP_DATA_FILE_BUCKET}}"
REACT_APP_QC_REPORT_BUCKET="${{secrets.REACT_APP_QC_REPORT_BUCKET}}"
REACT_APP_QC_REPORT_BUCKET_DEV="${{secrets.REACT_APP_QC_REPORT_BUCKET_DEV}}"
REACT_APP_ES_ACCESS_TOKEN="${{secrets.REACT_APP_ES_ACCESS_TOKEN}}"
REACT_APP_ES_ACCESS_TOKEN_DEV="${{secrets.REACT_APP_ES_ACCESS_TOKEN_DEV}}"
REACT_APP_reCAPTCHA_SITE_KEY="${{secrets.REACT_APP_reCAPTCHA_SITE_KEY}}"
REACT_APP_AUTH0_CLIENT_ID="${{secrets.REACT_APP_AUTH0_CLIENT_ID}}"
REACT_APP_QUALTRICS_SURVEY_URL="${{secrets.REACT_APP_QUALTRICS_SURVEY_URL}}"
REACT_APP_USER_SURVEY_SUBMIT_URL="${{secrets.REACT_APP_USER_SURVEY_SUBMIT_URL}}"
REACT_APP_USER_SURVEY_INPUT_1="${{secrets.REACT_APP_USER_SURVEY_INPUT_1}}"
REACT_APP_USER_SURVEY_INPUT_2="${{secrets.REACT_APP_USER_SURVEY_INPUT_2}}"
REACT_APP_USER_SURVEY_INPUT_3="${{secrets.REACT_APP_USER_SURVEY_INPUT_3}}"
REACT_APP_USER_SURVEY_INPUT_4="${{secrets.REACT_APP_USER_SURVEY_INPUT_4}}"
REACT_APP_USER_SURVEY_INPUT_5="${{secrets.REACT_APP_USER_SURVEY_INPUT_5}}"
REACT_APP_OFFICE_HOUR_DAY="${{secrets.REACT_APP_OFFICE_HOUR_DAY}}"
REACT_APP_OFFICE_HOUR_DATE="${{secrets.REACT_APP_OFFICE_HOUR_DATE}}"
REACT_APP_OFFICE_HOUR_SIGNUP_URL="${{secrets.REACT_APP_OFFICE_HOUR_SIGNUP_URL}}"
- name: Build and push server image
- name: Build and push server image (dev)
if: github.ref != 'refs/heads/master'
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile.dev
tags: |
us-docker.pkg.dev/${{ env.PROJECT_ID }}/datahub/frontend:${{ github.sha }}
us-docker.pkg.dev/${{ env.PROJECT_ID }}/datahub/frontend:${{ env.PACKAGE_VERSION }}
us-docker.pkg.dev/${{ env.PROJECT_ID }}/datahub/frontend:latest
us-docker.pkg.dev/motrpac-portal-dev/datahub/frontend:${{ github.sha }}
us-docker.pkg.dev/motrpac-portal-dev/datahub/frontend:${{ env.PACKAGE_VERSION }}
us-docker.pkg.dev/motrpac-portal-dev/datahub/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
Expand Down
102 changes: 102 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# create-react-app build environment
FROM node:20-alpine as react-build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH

COPY package*.json yarn.lock ./
RUN --mount=type=cache,target=/root/.yarn \
YARN_CACHE_FOLDER=/root/.yarn JOBS=max \
yarn install --network-timeout 1000000

COPY src ./src
COPY public ./public
RUN --mount=type=cache,target=/root/.yarn \
YARN_CACHE_FOLDER=/root/.yarn JOBS=max \
yarn sass

ARG REACT_APP_ES_PROXY_HOST
ARG REACT_APP_ES_PROXY_HOST_DEV
ARG REACT_APP_API_SERVICE_ADDRESS
ARG REACT_APP_API_SERVICE_ADDRESS_DEV
ARG REACT_APP_API_SERVICE_KEY
ARG REACT_APP_API_SERVICE_KEY_DEV
ARG REACT_APP_SIGNED_URL_ENDPOINT
ARG REACT_APP_USER_REGISTRATION_ENDPOINT
ARG REACT_APP_SEND_EMAIL_ENDPOINT
ARG REACT_APP_FILE_DOWNLOAD_ENDPOINT
ARG REACT_APP_QC_DATA_ENDPOINT
ARG REACT_APP_ES_ENDPOINT
ARG REACT_APP_FILE_SEARCH_ENDPOINT
ARG REACT_APP_DATA_FILE_BUCKET
ARG REACT_APP_QC_REPORT_BUCKET
ARG REACT_APP_QC_REPORT_BUCKET_DEV
ARG REACT_APP_ES_ACCESS_TOKEN
ARG REACT_APP_ES_ACCESS_TOKEN_DEV
ARG REACT_APP_reCAPTCHA_SITE_KEY
ARG REACT_APP_AUTH0_CLIENT_ID
ARG REACT_APP_QUALTRICS_SURVEY_URL
ARG REACT_APP_USER_SURVEY_SUBMIT_URL
ARG REACT_APP_USER_SURVEY_INPUT_1
ARG REACT_APP_USER_SURVEY_INPUT_2
ARG REACT_APP_USER_SURVEY_INPUT_3
ARG REACT_APP_USER_SURVEY_INPUT_4
ARG REACT_APP_USER_SURVEY_INPUT_5
ARG REACT_APP_OFFICE_HOUR_DAY
ARG REACT_APP_OFFICE_HOUR_DATE
ARG REACT_APP_OFFICE_HOUR_SIGNUP_URL

ENV ESLINT_NO_DEV_ERRORS true
ENV DISABLE_ESLINT_PLUGIN true
ENV REACT_APP_ES_PROXY_HOST $REACT_APP_ES_PROXY_HOST
ENV REACT_APP_ES_PROXY_HOST_DEV $REACT_APP_ES_PROXY_HOST_DEV
ENV REACT_APP_API_SERVICE_ADDRESS $REACT_APP_API_SERVICE_ADDRESS
ENV REACT_APP_API_SERVICE_ADDRESS_DEV $REACT_APP_API_SERVICE_ADDRESS_DEV
ENV REACT_APP_API_SERVICE_KEY $REACT_APP_API_SERVICE_KEY
ENV REACT_APP_API_SERVICE_KEY_DEV $REACT_APP_API_SERVICE_KEY_DEV
ENV REACT_APP_SIGNED_URL_ENDPOINT $REACT_APP_SIGNED_URL_ENDPOINT
ENV REACT_APP_USER_REGISTRATION_ENDPOINT $REACT_APP_USER_REGISTRATION_ENDPOINT
ENV REACT_APP_SEND_EMAIL_ENDPOINT $REACT_APP_SEND_EMAIL_ENDPOINT
ENV REACT_APP_FILE_DOWNLOAD_ENDPOINT $REACT_APP_FILE_DOWNLOAD_ENDPOINT
ENV REACT_APP_QC_DATA_ENDPOINT $REACT_APP_QC_DATA_ENDPOINT
ENV REACT_APP_ES_ENDPOINT $REACT_APP_ES_ENDPOINT
ENV REACT_APP_FILE_SEARCH_ENDPOINT $REACT_APP_FILE_SEARCH_ENDPOINT
ENV REACT_APP_DATA_FILE_BUCKET $REACT_APP_DATA_FILE_BUCKET
ENV REACT_APP_QC_REPORT_BUCKET $REACT_APP_QC_REPORT_BUCKET
ENV REACT_APP_QC_REPORT_BUCKET_DEV $REACT_APP_QC_REPORT_BUCKET_DEV
ENV REACT_APP_ES_ACCESS_TOKEN $REACT_APP_ES_ACCESS_TOKEN
ENV REACT_APP_ES_ACCESS_TOKEN_DEV $REACT_APP_ES_ACCESS_TOKEN_DEV
ENV REACT_APP_reCAPTCHA_SITE_KEY $REACT_APP_reCAPTCHA_SITE_KEY
ENV REACT_APP_AUTH0_CLIENT_ID $REACT_APP_AUTH0_CLIENT_ID
ENV REACT_APP_QUALTRICS_SURVEY_URL $REACT_APP_QUALTRICS_SURVEY_URL
ENV REACT_APP_USER_SURVEY_SUBMIT_URL $REACT_APP_USER_SURVEY_SUBMIT_URL
ENV REACT_APP_USER_SURVEY_INPUT_1 $REACT_APP_USER_SURVEY_INPUT_1
ENV REACT_APP_USER_SURVEY_INPUT_2 $REACT_APP_USER_SURVEY_INPUT_2
ENV REACT_APP_USER_SURVEY_INPUT_3 $REACT_APP_USER_SURVEY_INPUT_3
ENV REACT_APP_USER_SURVEY_INPUT_4 $REACT_APP_USER_SURVEY_INPUT_4
ENV REACT_APP_USER_SURVEY_INPUT_5 $REACT_APP_USER_SURVEY_INPUT_5
ENV REACT_APP_OFFICE_HOUR_DAY $REACT_APP_OFFICE_HOUR_DAY
ENV REACT_APP_OFFICE_HOUR_DATE $REACT_APP_OFFICE_HOUR_DATE
ENV REACT_APP_OFFICE_HOUR_SIGNUP_URL $REACT_APP_OFFICE_HOUR_SIGNUP_URL
ENV NODE_ENV development

RUN --mount=type=cache,target=/root/.yarn \
YARN_CACHE_FOLDER=/root/.yarn JOBS=max \
yarn build

# nginx server environment
FROM nginxinc/nginx-unprivileged:1.25-alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=react-build /app/build /usr/share/nginx/html

LABEL org.opencontainers.image.description="MoTrPAC Data Portal Docker Image"
LABEL org.opencontainers.image.documentation="https://github.com/MoTrPAC/motrpac-frontend"
LABEL org.opencontainers.image.title="MoTrPAC Data Portal Web Client Server"
LABEL org.opencontainers.image.url="https://motrpac-data.org"
LABEL org.opencontainers.image.vendor="MoTrPAC"
LABEL org.opencontainers.image.version=$IMAGE_VERSION

ENV NODE_ENV dev

EXPOSE 8080

42 changes: 42 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
web:
platform: linux/amd64
image: motrpac-frontend:latest
ports:
- 34928:8080
build:
context: .
dockerfile: Dockerfile.dev
args:
ESLINT_NO_DEV_ERRORS: true
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}
REACT_APP_QUALTRICS_SURVEY_URL: ${REACT_APP_QUALTRICS_SURVEY_URL}
REACT_APP_USER_SURVEY_SUBMIT_URL: ${REACT_APP_USER_SURVEY_SUBMIT_URL}
REACT_APP_USER_SURVEY_INPUT_1: ${REACT_APP_USER_SURVEY_INPUT_1}
REACT_APP_USER_SURVEY_INPUT_2: ${REACT_APP_USER_SURVEY_INPUT_2}
REACT_APP_USER_SURVEY_INPUT_3: ${REACT_APP_USER_SURVEY_INPUT_3}
REACT_APP_USER_SURVEY_INPUT_4: ${REACT_APP_USER_SURVEY_INPUT_4}
REACT_APP_USER_SURVEY_INPUT_5: ${REACT_APP_USER_SURVEY_INPUT_5}
REACT_APP_OFFICE_HOUR_DAY: ${REACT_APP_OFFICE_HOUR_DAY}
REACT_APP_OFFICE_HOUR_DATE: ${REACT_APP_OFFICE_HOUR_DATE}
REACT_APP_OFFICE_HOUR_SIGNUP_URL: ${REACT_APP_OFFICE_HOUR_SIGNUP_URL}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MoTrPAC",
"version": "2.0.0-dev.3",
"version": "2.0.0-dev.5",
"private": true,
"dependencies": {
"auth0-js": "9.20.0",
Expand Down

0 comments on commit 127593b

Please sign in to comment.