diff --git a/.circleci/config.yml b/.circleci/config.yml index 6184f78..44dae20 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,6 +71,27 @@ jobs: exit 1 fi + docker-build-and-push: + working_directory: /dockerapp + docker: + - image: docker:17.05.0-ce-git + steps: + - checkout + - setup_remote_docker: + version: 20.10.11 + - 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 $DOCKERHUB_EMAIL -u $DOCKERHUB_USERID -p $DOCKERHUB_PASSWORD + docker tag app $DOCKERHUB_USERID/20212022devopsfinalbackend:$CIRCLE_BUILD_NUM + docker tag app $DOCKERHUB_USERID/20212022devopsfinalbackend:finalApp + docker push $DOCKERHUB_USERID/20212022devopsfinalbackend:$CIRCLE_BUILD_NUM + docker push $DOCKERHUB_USERID/20212022devopsfinalbackend:finalApp + workflows: version: 2 build-test-and-lint: @@ -86,6 +107,15 @@ workflows: requires: - build - back-deploy-heroku: + requires: + - build + - lint + - back-test-e2e + - back-test-unit + filters: + branches: + only: main + - docker-build-and-push: requires: - build - lint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d543a06 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:14.15.0 + +WORKDIR /repo + +COPY . /repo + +RUN yarn install + +RUN yarn build + +ENTRYPOINT [ "yarn", "start:prod" ] \ No newline at end of file