Skip to content

Instantly share code, notes, and snippets.

@Lucasdsk
Created March 30, 2023 15:55
Show Gist options
  • Save Lucasdsk/065f0f9c225c788fb99ee1a5f7612239 to your computer and use it in GitHub Desktop.
Save Lucasdsk/065f0f9c225c788fb99ee1a5f7612239 to your computer and use it in GitHub Desktop.
FROM node:18.15.0-alpine3.17 as builder
ARG VITE_FIREBASE_WEB_APP_API_KEY
ARG VITE_FIREBASE_PROJECT_ID
ARG VITE_ATHENAHEALTH_BASE_URL
ARG VITE_ATHENAHEALTH_PRACTICE_ID
# Install Required packages.
RUN apk --no-cache add curl python3 bash git ca-certificates \
&& addgroup -S app && adduser -S -g app app
WORKDIR /root/
################### NPM ENV ####################
# Turn down the verbosity to default level.
ENV NPM_CONFIG_LOGLEVEL error
ENV NODE_MODULES_CACHE=false
################################################
RUN mkdir -p /home/app
WORKDIR /home/app
# Copy source code
COPY ./ ./
COPY ./.env.deployment.development ./.env
RUN npm config set unsafe-perm true
# Parse secrets
COPY ./__infrastructure/secret-parser.sh ./secret-parser.sh
RUN chmod +x ./secret-parser.sh
# Yarn install (Make sure yarn.lock is stable.)
RUN yarn install
# Downloading gcloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
# Installing the package
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh
# Adding the package path to local
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
RUN bash -c "VITE_FIREBASE_PROJECT_ID=${VITE_FIREBASE_PROJECT_ID} VITE_FIREBASE_WEB_APP_API_KEY=${VITE_FIREBASE_WEB_APP_API_KEY} VITE_ATHENAHEALTH_BASE_URL=${VITE_ATHENAHEALTH_BASE_URL} VITE_ATHENAHEALTH_PRACTICE_ID=${VITE_ATHENAHEALTH_PRACTICE_ID} ./secret-parser.sh 'yarn build'"
################### ENVs ################
ENV NODE_ENV=development
#########################################
# @TODO Setup a health-check
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
FROM nginx
EXPOSE 8080
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /home/app/build /usr/share/nginx/html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment