Skip to content

Commit 66a1495

Browse files
committed
daemon dockerfile and local commands
1 parent 61252ba commit 66a1495

File tree

9 files changed

+127
-6
lines changed

9 files changed

+127
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ lib
88
task-definition/scorekeep-task-definition.json
99
.elasticbeanstalk/*
1010

11+
aws.env

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ tag: package check-env
2626
docker tag scorekeep-api:latest $(ECR_REPO)
2727

2828
run-local: package check-env
29-
docker run -d -v ~/.aws/:/root/.aws/:ro --net=host -e AWS_REGION=$(AWS_REGION) -e NOTIFICATION_TOPIC=arn:aws:sns:$(AWS_REGION):$(ACCOUNT_ID):scorekeep-notifications scorekeep-api
29+
docker run -v ~/.aws/:/root/.aws/:ro --net=host --attach STDOUT -e AWS_REGION=$(AWS_REGION) -e NOTIFICATION_TOPIC=arn:aws:sns:$(AWS_REGION):$(ACCOUNT_ID):scorekeep-notifications --name scorekeep-api scorekeep-api
30+
31+
stop-local:
32+
docker stop scorekeep-api && docker rm scorekeep-api
3033

3134
login: check-region
3235
@$(shell aws ecr get-login --no-include-email --region $(AWS_REGION))

scorekeep-frontend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
FROM nginx
22
ADD public /public
33
ADD nginx.conf /etc/nginx/nginx.conf
4+
EXPOSE 80

task-definition/generate-dockerrun

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
TASK_DEFINITION_INPUT_FILE="scorekeep-dockerrun-aws.template"
7+
TASK_DEFINITION_INPUT_PATH="${DIR}/template/${TASK_DEFINITION_INPUT_FILE}"
8+
9+
TASK_DEFINITION_OUTPUT_FILE="Dockerrun.aws.json"
10+
TASK_DEFINITION_OUTPUT_PATH="${DIR}/${TASK_DEFINITION_OUTPUT_FILE}"
11+
12+
PARAMETERS_FILE="../aws.env"
13+
PARAMETERS_PATH="${DIR}/${PARAMETERS_FILE}"
14+
15+
echo "Sourcing paramters from ${PARAMETERS_PATH}"
16+
source ${PARAMETERS_PATH}
17+
18+
if [[ -z "${ACCOUNT_ID}" || -z "${AWS_REGION}" ]]; then
19+
echo "Must specify both ACCOUNT_ID and AWS_REGION in ${PARAMETERS_PATH}"
20+
exit 1
21+
fi
22+
23+
echo "Configuring region to: ${AWS_REGION}"
24+
echo "Configuring account id to: ${ACCOUNT_ID}"
25+
26+
sed -e 's/\$\$REGION\$\$/'"${AWS_REGION}"'/g' -e 's/\$\$ACCOUNT_ID\$\$/'"${ACCOUNT_ID}"'/g' ${TASK_DEFINITION_INPUT_PATH} > ${TASK_DEFINITION_OUTPUT_PATH}
27+
28+
echo "Task Definition written to: ${TASK_DEFINITION_OUTPUT_PATH}"

task-definition/generate-task-definition

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66
TASK_DEFINITION_INPUT_FILE="scorekeep-task-definition.template"
77
TASK_DEFINITION_INPUT_PATH="${DIR}/template/${TASK_DEFINITION_INPUT_FILE}"
88

9-
TASK_DEFINITION_OUTPUT_FILE="Dockerrun.aws.json"
9+
TASK_DEFINITION_OUTPUT_FILE="scorekeep-task-definition.json"
1010
TASK_DEFINITION_OUTPUT_PATH="${DIR}/${TASK_DEFINITION_OUTPUT_FILE}"
1111

1212
PARAMETERS_FILE="../aws.env"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"AWSEBDockerrunVersion": 2,
3+
"family": "scorekeep",
4+
"containerDefinitions": [
5+
{
6+
"name": "scorekeep-frontend",
7+
"image": "$$ACCOUNT_ID$$.dkr.ecr.$$REGION$$.amazonaws.com/scorekeep-frontend",
8+
"cpu": 32,
9+
"memoryReservation": 256,
10+
"portMappings" : [
11+
{
12+
"hostPort": 80,
13+
"containerPort": 80
14+
}
15+
],
16+
"links": [
17+
"scorekeep-api"
18+
],
19+
"logConfiguration": {
20+
"logDriver": "awslogs",
21+
"options": {
22+
"awslogs-group": "scorekeep",
23+
"awslogs-region": "$$REGION$$",
24+
"awslogs-stream-prefix": "scorekeep/frontend"
25+
}
26+
}
27+
},
28+
{
29+
"name": "xray-daemon",
30+
"image": "$$ACCOUNT_ID$$.dkr.ecr.$$REGION$$.amazonaws.com/xray-daemon",
31+
"cpu": 32,
32+
"memoryReservation": 256,
33+
"portMappings" : [
34+
{
35+
"hostPort": 2000,
36+
"containerPort": 2000,
37+
"protocol": "udp"
38+
}
39+
],
40+
"logConfiguration": {
41+
"logDriver": "awslogs",
42+
"options": {
43+
"awslogs-group": "scorekeep",
44+
"awslogs-region": "$$REGION$$",
45+
"awslogs-stream-prefix": "scorekeep/daemon"
46+
}
47+
}
48+
},
49+
{
50+
"name": "scorekeep-api",
51+
"image": "$$ACCOUNT_ID$$.dkr.ecr.$$REGION$$.amazonaws.com/scorekeep-api",
52+
"cpu": 192,
53+
"memoryReservation": 512,
54+
"environment": [
55+
{ "name" : "AWS_REGION", "value" : "$$REGION$$" },
56+
{ "name" : "NOTIFICATION_TOPIC", "value" : "arn:aws:sns:$$REGION$$:$$ACCOUNT_ID$$:scorekeep-notifications" },
57+
{ "name" : "AWS_XRAY_DAEMON_ADDRESS", "value" : "xray-daemon:2000" }
58+
],
59+
"portMappings" : [
60+
{
61+
"hostPort": 5000,
62+
"containerPort": 5000
63+
}
64+
],
65+
"links": [
66+
"xray-daemon"
67+
],
68+
"logConfiguration": {
69+
"logDriver": "awslogs",
70+
"options": {
71+
"awslogs-group": "scorekeep",
72+
"awslogs-region": "$$REGION$$",
73+
"awslogs-stream-prefix": "scorekeep/api"
74+
}
75+
}
76+
}
77+
],
78+
"executionRoleArn": "arn:aws:iam::$$ACCOUNT_ID$$:role/scorekeepExecutionRole",
79+
"taskRoleArn": "arn:aws:iam::$$ACCOUNT_ID$$:role/scorekeepRole",
80+
"cpu": ".25 vcpu",
81+
"memory": "1 gb"
82+
}

task-definition/template/scorekeep-task-definition.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"AWSEBDockerrunVersion": 2,
32
"family": "scorekeep",
43
"containerDefinitions": [
54
{

xray-daemon/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
FROM amazonlinux
2-
COPY xray /usr/bin/xray
3-
ENTRYPOINT ["/usr/bin/xray", "-b", "0.0.0.0:2000"]
2+
RUN yum install -y unzip
3+
RUN curl -o daemon.zip https://s3.dualstack.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-2.x.zip
4+
RUN unzip daemon.zip -d /
5+
COPY /xray /usr/bin/xray
6+
EXPOSE 2000/udp
7+
ENTRYPOINT ["/usr/bin/xray", "-b", "0.0.0.0:2000"]

xray-daemon/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ check-region:
1818
check-env: check-repo check-region check-account
1919

2020
run-local: package check-env
21-
docker run -d --net=host xray-daemon
21+
docker run --attach STDOUT -v ~/.aws/:/root/.aws/:ro --net=host -e AWS_REGION=$(AWS_REGION) --name xray-daemon xray-daemon -o
22+
23+
stop-local:
24+
docker stop xray-daemon && docker rm xray-daemon
2225

2326
tag: package check-env
2427
docker tag xray-daemon:latest $(ECR_REPO)

0 commit comments

Comments
 (0)