Skip to content

Commit ac7a4aa

Browse files
committed
Adding Dockerfile and buildspec.yml
1 parent 9448835 commit ac7a4aa

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Diff for: Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node:16-alpine
2+
ENV AWS_CLI_VERSION 1.15.47
3+
WORKDIR /app
4+
5+
#copy all the app files
6+
COPY . .
7+
8+
RUN apk --no-cache update
9+
10+
RUN apk add --no-cache build-base rsync git
11+
12+
#install packages for aws-env
13+
RUN apk add --no-cache python3 py-pip py-setuptools groff less openssl ca-certificates bash && \
14+
pip --no-cache-dir install awscli==${AWS_CLI_VERSION} && \
15+
rm -rf /var/cache/apk/*
16+
17+
#Download aws-env
18+
RUN wget https://github.com/Droplr/aws-env/raw/master/bin/aws-env-linux-amd64 -O /bin/aws-env && chmod +x /bin/aws-env
19+
20+
#Install dependencies and build
21+
RUN yarn install && yarn build && yarn add serve
22+
23+
CMD eval $(aws-env) && yarn serve build

Diff for: buildspec.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 0.2
2+
3+
env:
4+
git-credential-helper: yes
5+
parameter-store:
6+
DOCKER_HUB_USER: '/devops/shared/DOCKER_HUB_USER'
7+
DOCKER_HUB_PASSWORD: '/devops/shared/DOCKER_HUB_PASSWORD'
8+
9+
phases:
10+
install:
11+
runtime-versions:
12+
nodejs: 14
13+
commands:
14+
- n 16
15+
- npm update -g npm
16+
- aws --version
17+
- node -v
18+
pre_build:
19+
commands:
20+
- export APP_BUILD_VERSION=${CODEBUILD_RESOLVED_SOURCE_VERSION}__$(date -u '+%Y-%m-%dT%T+00:00')
21+
- echo $APP_BUILD_VERSION > ./src/.version
22+
- cat ./src/.version
23+
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $DOCKER_REPOSITORY_URI
24+
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
25+
build:
26+
commands:
27+
- echo $DOCKER_HUB_PASSWORD | docker login --username $DOCKER_HUB_USER --password-stdin
28+
- docker build -t $DOCKER_REPOSITORY_URI:latest .
29+
- docker tag $DOCKER_REPOSITORY_URI:latest $DOCKER_REPOSITORY_URI:$IMAGE_TAG
30+
post_build:
31+
commands:
32+
- docker push $DOCKER_REPOSITORY_URI:latest
33+
- docker push $DOCKER_REPOSITORY_URI:$IMAGE_TAG
34+
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $DOCKER_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
35+
artifacts:
36+
files:
37+
- imagedefinitions.json

0 commit comments

Comments
 (0)