Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit b77977b

Browse files
(feat): Adds Discounts React Application (#194)
* adds discounts react app * renames docker-compose file * add dockerfile * add workflow * roll back vite version * fix ref * replace katacoda with instruqt Co-authored-by: Colin Cole <colin.cole@datadoghq.com>
1 parent ece2fab commit b77977b

29 files changed

+4823
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Discounts React App Test and Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- discounts-react-app/**
9+
workflow_dispatch:
10+
branches: [ main ]
11+
12+
defaults:
13+
run:
14+
working-directory: discounts-react-app
15+
16+
jobs:
17+
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v1
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v1
31+
32+
- name: Configure AWS credentials
33+
uses: aws-actions/configure-aws-credentials@v1
34+
with:
35+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
36+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
37+
aws-region: us-east-1
38+
39+
- name: Login to ECR
40+
id: login-ecr
41+
uses: docker/login-action@v1
42+
with:
43+
registry: public.ecr.aws
44+
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
45+
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v2
49+
with:
50+
context: ./discounts-react-app
51+
platforms: linux/amd64
52+
push: true
53+
tags: ${{ secrets.PUBLIC_ECR_REGISTRY }}/ddtraining/discounts-react-app:latest
54+
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Docker compose file which uses build context plus mounted volumes for easier local development
2+
# Note: storefront-fixed cannot use the build context because the .patch files are located in a parent directory of the Dockerfile
3+
version: '3'
4+
services:
5+
agent:
6+
image: "datadog/agent:7.29.0"
7+
environment:
8+
- DD_API_KEY
9+
- DD_APM_ENABLED=true
10+
- DD_LOGS_ENABLED=true
11+
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
12+
- DD_PROCESS_AGENT_ENABLED=true
13+
- DD_DOCKER_LABELS_AS_TAGS={"my.custom.label.team":"team"}
14+
- DD_TAGS='env:development'
15+
ports:
16+
- "8126:8126"
17+
volumes:
18+
- /var/run/docker.sock:/var/run/docker.sock:ro
19+
- /proc/:/host/proc/:ro
20+
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
21+
labels:
22+
com.datadoghq.ad.logs: '[{"source": "agent", "service": "agent"}]'
23+
discounts:
24+
environment:
25+
- FLASK_APP=discounts.py
26+
- FLASK_DEBUG=1
27+
- POSTGRES_PASSWORD
28+
- POSTGRES_USER
29+
- POSTGRES_HOST=db
30+
- DD_SERVICE=discounts-service
31+
- DD_AGENT_HOST=agent
32+
- DD_LOGS_INJECTION=true
33+
- DD_TRACE_ANALYTICS_ENABLED=true
34+
- DD_PROFILING_ENABLED=true
35+
- DD_VERSION=1.1
36+
build:
37+
context: ../../discounts-service
38+
volumes:
39+
- "../../discounts-service:/app"
40+
ports:
41+
- "5001:5001"
42+
- "22"
43+
depends_on:
44+
- agent
45+
- db
46+
labels:
47+
com.datadoghq.ad.logs: '[{"source": "python", "service": "discounts-service"}]'
48+
my.custom.label.team: "discount"
49+
frontend:
50+
environment:
51+
- DD_AGENT_HOST=agent
52+
- DD_LOGS_INJECTION=true
53+
- DD_TRACE_ANALYTICS_ENABLED=true
54+
- DD_SERVICE=store-frontend
55+
- DB_USERNAME
56+
- DB_PASSWORD
57+
- DD_VERSION=1.1
58+
- DD_CLIENT_TOKEN
59+
- DD_APPLICATION_ID
60+
- DD_ENV=development
61+
- DD_SITE=datadoghq.com
62+
- RAILS_HIDE_STACKTRACE=true
63+
image: "ddtraining/storefront-fixed:latest"
64+
volumes:
65+
- "../../store-frontend/src/store-frontend-instrumented-fixed:/app"
66+
ports:
67+
- "3000:3000"
68+
depends_on:
69+
- agent
70+
- db
71+
- discounts
72+
- advertisements
73+
labels:
74+
com.datadoghq.ad.logs: '[{"source": "ruby", "service": "store-frontend"}]'
75+
my.custom.label.team: "frontend"
76+
advertisements:
77+
environment:
78+
- FLASK_APP=ads.py
79+
- FLASK_DEBUG=1
80+
- POSTGRES_PASSWORD
81+
- POSTGRES_USER
82+
- POSTGRES_HOST=db
83+
- DD_SERVICE=advertisements-service
84+
- DD_AGENT_HOST=agent
85+
- DD_LOGS_INJECTION=true
86+
- DD_TRACE_ANALYTICS_ENABLED=true
87+
- DD_PROFILING_ENABLED=true
88+
- DD_VERSION=1.0
89+
build:
90+
context: ../../ads-service-fixed
91+
volumes:
92+
- "../../ads-service-fixed:/app"
93+
ports:
94+
- "5002:5002"
95+
depends_on:
96+
- agent
97+
- db
98+
labels:
99+
com.datadoghq.ad.logs: '[{"source": "python", "service": "ads-service"}]'
100+
my.custom.label.team: "advertisements"
101+
db:
102+
image: postgres:11-alpine
103+
restart: always
104+
environment:
105+
- POSTGRES_PASSWORD
106+
- POSTGRES_USER
107+
labels:
108+
com.datadoghq.ad.logs: '[{"source": "postgresql", "service": "postgres"}]'
109+
attackbox:
110+
build:
111+
context: ../../attackbox
112+
logging:
113+
driver: none # this only works when using docker-compose (vs docker compose)
114+
environment:
115+
- ATTACK_GOBUSTER
116+
- ATTACK_HYDRA
117+
- ATTACK_GOBUSTER_INTERVAL
118+
- ATTACK_HYDRA_INTERVAL
119+
- ATTACK_SSH
120+
- ATTACK_SSH_INTERVAL
121+
- ATTACK_HOST
122+
- ATTACK_PORT
123+
depends_on:
124+
- discounts
125+
- frontend
126+
nginx:
127+
restart: always
128+
build:
129+
context: ../../nginx
130+
ports:
131+
- "80:80"
132+
depends_on:
133+
- frontend
134+
labels:
135+
com.datadoghq.ad.logs: '[{"source": "nginx", "service": "nginx"}]'
136+
puppeteer:
137+
image: buildkite/puppeteer:10.0.0
138+
environment:
139+
- STOREDOG_URL
140+
- DISCOUNTS_FRONTEND_URL
141+
depends_on:
142+
- frontend
143+
- discounts-frontend
144+
command: bash puppeteer.sh
145+
discounts-frontend:
146+
build:
147+
context: ../../discounts-react-app
148+
stdin_open: true
149+
ports:
150+
- '3001:80'
151+
environment:
152+
- REACT_APP_DD_ADS_URL
153+
- REACT_APP_DD_DISCOUNTS_URL
154+
- REACT_APP_STOREDOG_URL
155+
- REACT_APP_DD_APPLICATION_ID
156+
- REACT_APP_DD_CLIENT_TOKEN
157+
- REACT_APP_DD_ENV
158+
- REACT_APP_DD_SITE
159+
- REACT_APP_DD_VERSION
160+
- REACT_APP_DD_SERVICE
161+
# volumes:
162+
# - ../../discounts-react-app/src/main/dist:/usr/share/nginx/html
163+
# - ../../discounts-react-app/assets/nginx.conf:/etc/nginx/nginx.conf
164+
labels:
165+
com.datadoghq.ad.logs: '[{"source": "nginx", "service": "discounts-frontend"}]'
166+
com.datadoghq.ad.check_names: '["nginx"]'
167+
com.datadoghq.ad.init_configs: '[{}]'
168+
com.datadoghq.ad.instances: '[{"nginx_status_url": "http://%%host%%:81/nginx_status/"}]'
169+
com.datadoghq.tags.env: 'frontend-issues-2'
170+
com.datadoghq.tags.service: 'discounts-frontend'
171+
com.datadoghq.tags.version: '1.1'
172+
my.custom.label.team: 'discounts'

discounts-react-app/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.dockerignore

discounts-react-app/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# build environment
2+
FROM node:13.12.0-alpine as build
3+
WORKDIR /app
4+
COPY ./src/main ./
5+
ENV PATH /app/node_modules/.bin:$PATH
6+
RUN npm ci
7+
RUN npm run-script build
8+
9+
# production environment
10+
FROM nginx:1.19.7
11+
COPY --from=build /app/dist /usr/share/nginx/html
12+
COPY ./assets/nginx.conf /etc/nginx/nginx.conf
13+
EXPOSE 80
14+
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)