diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..196730f5c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,21 @@ +version: 2.1 + +# using circleci orbs for easy understanding and clean ci setup +orbs: + aws-ecs: circleci/aws-ecs@3.0.0 + aws-ecr: circleci/aws-ecr@8.1.2 + +workflows: + build-and-deploy: + jobs: + - aws-ecr/build-and-push-image: + repo: "calculator" + # using commit information as tag + tag: "latest" + + - aws-ecs/deploy-service-update: + # making sure deployment is run only after successful image build and push + requires: + - aws-ecr/build-and-push-image + family: "calculator" + cluster: "calculator" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..97341ce1c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Base image +FROM node:16-alpine + +# Add group and user to avoid root user usage for security reasons. +RUN addgroup calgroup +RUN adduser -D caluser calgroup + +# copy source code and set up work directory +RUN mkdir /calculator +COPY . /calculator +WORKDIR /calculator + +# change ownership of work directory and use created user +RUN chown -R caluser:calgroup /calculator +USER caluser + +#intimate docker which port will be used +EXPOSE 3000 + +# Run application +RUN npm install +CMD ["npm", "start"] \ No newline at end of file