From 1d4d4736fee4708f4211dfa81b8ecffc456bafec Mon Sep 17 00:00:00 2001 From: sipe-daniel Date: Thu, 5 Nov 2020 23:26:52 +0100 Subject: [PATCH] feat(config.yml):add a docker build and push step I had : -Build your docker file using the tag app -Login to docker hub -Tag your app yourdockerhublogin/my-awesome-ci-expr:BUILDNUMBER (I will let you figure out how to get the build number) -Tag with yourdockerhublogin/my-awesome-ci-expr:latest -And finally, push it all to docker hub --- .circleci/config.yml | 21 ++++++++++++++++++++- Dockerfile | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 02920f8..bfa2a6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,7 +68,26 @@ jobs: steps: - checkout - restore_cache: + name: Restore Yarn Package Cache key: yarn-packages-v2{{ checksum "yarn.lock" }} - run: name: "E2e Test" - command: yarn test:e2e \ No newline at end of file + command: yarn test:e2e + buildandpush_docker: + environment: + IMAGE_NAME: sipedaniel/my-awesome-ci-expr + docker: + - image: circleci/buildpack-deps:stretch + steps: + - checkout + - setup_remote_docker + - run: docker image build --tag $IMAGE_NAME:app . + - run: docker load -i /tmp/workspace/image.tar + - run: + name: Login and Publish to Docker Hub + command: | + echo "etienne20045" | docker login --username sipedaniel --password-stdin + docker tag $IMAGE_NAME:app $IMAGE_NAME:$CIRCLE_BUILD_NUM + docker tag $IMAGE_NAME:app $IMAGE_NAME:latest + docker push $IMAGE_NAME:latest + docker push $IMAGE_NAME:$CIRCLE_BUILD_NUM \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9d7d2b3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM node:12.18 +COPY ["package.json", "yarn.lock", "./"] +RUN yarn install +COPY . . +CMD ["yarn", "start"] \ No newline at end of file