diff --git a/.gitignore b/.gitignore index 863c1df..2512fa3 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ yarn-error.log* # Coverage Reports coverage + +# Local Netlify folder +.netlify \ No newline at end of file diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..e7373dc --- /dev/null +++ b/netlify.toml @@ -0,0 +1,21 @@ +# example netlify.toml +[build] + command = "yarn run build" + functions = "functions" + publish = "." + + ## Uncomment to use this redirect for Single Page Applications like create-react-app. + ## Not needed for static site generators. + #[[redirects]] + # from = "/*" + # to = "/index.html" + # status = 200 + + ## (optional) Settings for Netlify Dev + ## https://github.com/netlify/cli/blob/master/docs/netlify-dev.md#project-detection + #[dev] + # command = "yarn start" # Command to start your dev server + # port = 3000 # Port that the dev server will be listening on + # publish = "dist" # Folder with the static content for _redirect file + + ## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/ diff --git a/public/.circleci/config.yml b/public/.circleci/config.yml new file mode 100644 index 0000000..96d57d9 --- /dev/null +++ b/public/.circleci/config.yml @@ -0,0 +1,83 @@ +workflows: + version: 2 + build-deploy_frontend: + jobs: + - install-dependencies + - build: + requires: + - install-dependencies + - front-deploy: + requires: + - build + - docker-build-and-push + +version: 2 +jobs: + install-dependencies: + docker: + - image: circleci/node:dubnium-browsers + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} + - dependencies- + - run: yarn global add node-gyp && yarn install + - save_cache: + paths: + - node_modules + key: dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} + + build: + docker: + - image: circleci/node:dubnium-browsers + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} + - dependencies- + - run: yarn build + - run: + name: Copy deployment artifacts to workspace + command: | + cp dist/ /tmp/dist -r + - store_artifacts: + path: /tmp/dist + - persist_to_workspace: + root: /tmp + paths: + - dist + +front-deploy: + docker: + - image: circleci/node:dubnium-browsers + working_directory: ~/dist + steps: + - attach_workspace: + at: /tmp + - run: + name: Deploy app + command: | + npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --dir /tmp/dist --prod + + docker-build-and-push: + docker: + - image: docker:17.05.0-ce-git + steps: + - checkout + - setup_remote_docker + - run: + name: Build application Docker image + command: | + docker build --cache-from=app -t app . + - deploy: + name: Publish application to docker hub + command: | + docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD + docker tag app $DOCKER_HUB_USER_ID/tp_final_devops_frontend:$CIRCLE_BUILD_NUM + docker tag app $DOCKER_HUB_USER_ID/tp_final_devops_frontend:latest + docker push $DOCKER_HUB_USER_ID/tp_final_devops_frontend:$CIRCLE_BUILD_NUM + docker push $DOCKER_HUB_USER_ID/tp_final_devops_frontend:latest