From cf20ceb2f2c80776105e47296192d755186341fb Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Date: Tue, 24 Sep 2019 16:01:28 -0300 Subject: [PATCH] fe|FEAT: Add build stage into circleCI --- .circleci/config.yml | 8 +++++++- Dockerfile | 13 +++++++++++++ Makefile | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c7898e..b79e58a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,4 +9,10 @@ jobs: - run: name: "Check security using Yarn Audit" command: | - make check-sec \ No newline at end of file + make check-sec + - run: + name: "Build files" + command: | + yarn global add react-scripts + yarn install + make build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..312d427 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Stage 1 - the build process +FROM node as build-deps +WORKDIR /usr/src/app +COPY package.json yarn.lock ./ +RUN yarn +COPY . ./ +RUN yarn build + +# Stage 2 - the production environment +FROM nginx:1.12-alpine +COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/Makefile b/Makefile index 6792c03..a6fff9d 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,10 @@ PROJECT := huskyCI-dashboard install: yarn install +## Builds static files from react app. +build: + yarn build + ## Runs locally using start command. run: yarn start @@ -25,6 +29,17 @@ check-sec: test: yarn test +## Creates a container image based on most recent dashboard code +build-container: + docker build . -t huskyci/dashboard + +## Starts huskyci/dashboard container +start-container: + docker run -p 8080:80 huskyci/dashboard + +## Builds and starts dashboard add using huskyci/dashboard container +run-container: build-container start-container + ## Shows this help message. help: printf "\n${COLOR_YELLOW}${PROJECT}\n------\n${COLOR_RESET}"