diff --git a/Dockerfile b/Dockerfile index 17df3cd..8b0c84a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,9 @@ WORKDIR /app # Bundle app source # COPY ./index.js . # COPY ./dist . -RUN mkdir other +RUN mkdir /other RUN mkdir /code +RUN mkdir /dist RUN apt-get update && \ apt-get install -y \ python3 \ @@ -20,17 +21,24 @@ RUN apt-get update && \ RUN pip3 --no-cache-dir install --upgrade awscli +ARG AWS_ACCESS_KEY_ID +ARG AWS_SECRET_ACCESS_KEY +ARG AWS_DEFAULT_REGION + +ENV AWS_ACCESS_KEY_ID $AWS_ACCESS_KEY_ID +ENV AWS_SECRET_ACCESS_KEY $AWS_SECRET_ACCESS_KEY +ENV AWS_DEFAULT_REGION $AWS_DEFAULT_REGION + + RUN aws s3 sync s3://vueproject-simulation/dist/ /code/ # COPY ./other/dist ./other - COPY package*.json ./ # If you are building your code for production # RUN npm ci --only=production -COPY dist ./other/dist -COPY /code/dist ./dist -COPY /code/index.js ./ +COPY ./dist /app/other/dist +RUN cp -r /code/dist /app/dist +RUN cp /code/index.js /app/ RUN npm install - ENTRYPOINT [ "node", "index.js"] \ No newline at end of file diff --git a/codebuild/buildspec.yml b/codebuild/buildspec.yml index 1355855..39ba83d 100644 --- a/codebuild/buildspec.yml +++ b/codebuild/buildspec.yml @@ -14,11 +14,14 @@ phases: - echo Build started on `date` - echo Logging in to Docker Hub... - docker login --username $username --password $password - - docker build -t crowd-simulation:v0.0.1 . --no-cache + - echo $AWS_ACCESS_KEY_ID + # - docker build -t crowd-simulation:v0.0.1 . AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION . --no-cache + - docker build -t crowd-simulation:v0.0.1 --build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY --build-arg AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION . --no-cache - docker tag crowd-simulation:v0.0.1 sarathkshatri/crowd-simulation:v0.0.1 + post_build: commands: - echo Build completed on `date` - echo Pushing the Docker image... - - docker push sarathkshatri/crowd-simulation:v0.0.1 + - docker push sarathkshatri/crowd-simulation:v0.0.1 \ No newline at end of file