Skip to content

Commit e2b8acb

Browse files
authored
Merge pull request #49 from datacamp/ludov/deployment
add deployment configuration
2 parents 38e7e48 + ae06eab commit e2b8acb

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 2.1
2+
orbs:
3+
datacamp-ecr: datacamp/ecr@1
4+
datacamp-deploy: datacamp/deploy@1
5+
cypress: datacamp/cypress@0
6+
7+
workflows:
8+
build-and-deploy:
9+
jobs:
10+
- datacamp-ecr/build_and_push_image_to_ecr:
11+
name: build
12+
context: org-global
13+
aws-access-key-id: $OPS_AWS_ACCESS_KEY_ID
14+
aws-secret-access-key: $OPS_AWS_SECRET_ACCESS_KEY
15+
account-url: $OPS_ECR_URL
16+
puller-account-ids: '["301258414863", "487088987264"]'
17+
- datacamp-deploy/deploy: # Staging
18+
context: org-global
19+
requires:
20+
- build
21+
new-deploy-opt-in: true
22+
deploy-url: $STAGING_LAMBDA_DEPLOY_URL
23+
deploy-password: $STAGING_LAMBDA_DEPLOY_PASSWORD
24+
filters:
25+
branches:
26+
only:
27+
- master
28+
- datacamp-deploy/deploy: # Production
29+
context: org-global
30+
new-deploy-opt-in: true
31+
deploy-url: $PROD_LAMBDA_DEPLOY_URL
32+
deploy-password: $PROD_LAMBDA_DEPLOY_PASSWORD
33+
filters:
34+
branches:
35+
only:
36+
- master

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG NODE_VERSION=12.14-alpine3.9
2+
3+
FROM node:${NODE_VERSION} as dependencies
4+
5+
WORKDIR /usr/app
6+
7+
# First copy only package.json & yarn.lock and run yarn install, this will make
8+
# docker cache these steps if those files didn't change
9+
COPY package.json yarn.lock ./
10+
RUN yarn install
11+
12+
# Copy all the other source files we need to build
13+
COPY . .
14+
15+
RUN yarn build
16+
17+
# Main
18+
FROM node:${NODE_VERSION}
19+
20+
RUN apk --no-cache add curl bash
21+
RUN mkdir -p /usr/src/app
22+
23+
WORKDIR /usr/src/app
24+
25+
# Only copy the files actually needed to run the app, this will make our docker
26+
# image significant smaller and we don't leak uncompiled source code to production
27+
COPY --from=dependencies /usr/app/package.json ./
28+
COPY --from=dependencies /usr/app/next.config.js ./
29+
COPY --from=dependencies /usr/app/node_modules ./node_modules
30+
COPY --from=dependencies /usr/app/.next ./.next
31+
COPY --from=dependencies /usr/app/public ./public
32+
33+
ENV PORT 3000
34+
EXPOSE 3000
35+
36+
CMD ["yarn", "start"]

ecs.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"cluster": "datacamp-services",
3+
"serviceName": "rdocumentation",
4+
"containers": [
5+
{
6+
"containerName": "rdocumentation",
7+
"containerURI": "708371444347.dkr.ecr.us-east-1.amazonaws.com/rdocumentation-2.0:${CIRCLE_SHA1}",
8+
"memoryReservation": 256,
9+
"cpu": 64,
10+
"essential": true,
11+
"containerPort": 3000,
12+
"healthCheck": {
13+
"command": [
14+
"CMD-SHELL",
15+
"curl -f http://localhost:3000/local_health || exit 1"
16+
],
17+
"interval": 10,
18+
"startPeriod": 30
19+
},
20+
"dockerLabels": {
21+
"com.datadoghq.ad.instances": "[{ \"name\": \"service_check\", \"url\": \"http://%%host%%:%%port%%/local_health\", \"tags\": [\"service:rdocumentation\"], \"allow_redirects\": false }]",
22+
"com.datadoghq.ad.check_names": "[\"http_check\"]",
23+
"com.datadoghq.ad.init_configs": "[{}]"
24+
}
25+
}
26+
],
27+
"deployment": {
28+
"strategy": "rollout",
29+
"parameters": {
30+
"gracePeriod": 60,
31+
"failureThreshold": 30,
32+
"window": 240,
33+
"interval": 10,
34+
"slackChannel": "deploys",
35+
"customMessage": "Deploying <https://github.com/datacamp/rdocumentation-2.0/tree/${CIRCLE_SHA1}|${CIRCLE_SHA1}>"
36+
}
37+
},
38+
"serviceMesh": {
39+
"enabled": true
40+
}
41+
}

0 commit comments

Comments
 (0)