diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..600e365 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +**/node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e91bcdb..4e478df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM node:12-alpine +FROM node:16-alpine +RUN apk add g++ make py3-pip ARG NODE_ENV=production ARG PORT=80 @@ -7,11 +8,9 @@ ENV PORT=${PORT} ENV NODE_ENV=${NODE_ENV} WORKDIR /usr/src/app - -COPY package.json ./ +COPY . . RUN npm install -COPY . . EXPOSE ${PORT} CMD [ "npm", "run", "start" ] \ No newline at end of file diff --git a/buildspec.yml b/buildspec.yml index 6c28f32..95317b6 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -1,27 +1,39 @@ # Do not change version. This is the version of aws buildspec, not the version of your buldspec file. version: 0.2 +env: + variables: + ECR_REPO: 517312321348.dkr.ecr.us-east-1.amazonaws.com/course-app + phases: install: runtime-versions: nodejs: 16 + docker: 18 pre_build: commands: - - echo Installing source NPM Depedencies... + - echo "Installing source NPM Depedencies.." - npm install + - echo "Run unit testing.." + - npm run test + - echo ${CODEBUILD_SOURCE_VERSION} build: commands: - - echo Run unit testing... - - npm run test + - echo "Build docker image.." + - docker build -t course-catalog . + - echo "Tangging docker image" + - docker tag ${ECR_REPO}:${CODEBUILD_SOURCE_VERSION} + - echo "Build image complete.." post_build: commands: - - echo Build completed... + - echo "Build completed.." + - $(aws ecr get-login --no-include-email --region eu-west-1) reports: test-report: #surefire junit reports files: - 'test-result.xml' - base-directory: 'report/*' + file-format: JUNITXML artifacts: files: