Skip to content

Commit

Permalink
Adding Dockerfile and buildspec.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelomilera committed Jun 15, 2022
1 parent 9448835 commit ac7a4aa
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:16-alpine
ENV AWS_CLI_VERSION 1.15.47
WORKDIR /app

#copy all the app files
COPY . .

RUN apk --no-cache update

RUN apk add --no-cache build-base rsync git

#install packages for aws-env
RUN apk add --no-cache python3 py-pip py-setuptools groff less openssl ca-certificates bash && \
pip --no-cache-dir install awscli==${AWS_CLI_VERSION} && \
rm -rf /var/cache/apk/*

#Download aws-env
RUN wget https://github.com/Droplr/aws-env/raw/master/bin/aws-env-linux-amd64 -O /bin/aws-env && chmod +x /bin/aws-env

#Install dependencies and build
RUN yarn install && yarn build && yarn add serve

CMD eval $(aws-env) && yarn serve build
37 changes: 37 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 0.2

env:
git-credential-helper: yes
parameter-store:
DOCKER_HUB_USER: '/devops/shared/DOCKER_HUB_USER'
DOCKER_HUB_PASSWORD: '/devops/shared/DOCKER_HUB_PASSWORD'

phases:
install:
runtime-versions:
nodejs: 14
commands:
- n 16
- npm update -g npm
- aws --version
- node -v
pre_build:
commands:
- export APP_BUILD_VERSION=${CODEBUILD_RESOLVED_SOURCE_VERSION}__$(date -u '+%Y-%m-%dT%T+00:00')
- echo $APP_BUILD_VERSION > ./src/.version
- cat ./src/.version
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $DOCKER_REPOSITORY_URI
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
build:
commands:
- echo $DOCKER_HUB_PASSWORD | docker login --username $DOCKER_HUB_USER --password-stdin
- docker build -t $DOCKER_REPOSITORY_URI:latest .
- docker tag $DOCKER_REPOSITORY_URI:latest $DOCKER_REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- docker push $DOCKER_REPOSITORY_URI:latest
- docker push $DOCKER_REPOSITORY_URI:$IMAGE_TAG
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $DOCKER_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json

0 comments on commit ac7a4aa

Please sign in to comment.