Skip to content

Instantly share code, notes, and snippets.

Avatar
📦
Bin packing containers onto hosts

Nathan Peck nathanpeck

📦
Bin packing containers onto hosts
View GitHub Profile
View task-definition.yml
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref 'ServiceName'
Cpu: !Ref 'ContainerCpu'
Memory: !Ref 'ContainerMemory'
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn:
View vue-typing.js
var store = {
data: {
typing: []
},
addTyper: function(typer) {
this.data.typing.push(typer);
}
};
View main-content.html
<div id="content" class="content">
<room-details></room-details>
<messages></messages>
<typing></typing>
</div>
View query.js
messages = await this.dynamoDB.query({
TableName: this.tableName,
KeyConditionExpression: 'room = :room',
Limit: 20,
ExpressionAttributeValues: {
':room': where.room
},
ExclusiveStartKey: where.message ? where : undefined,
ScanIndexForward: false // Always return newest items first
}).promise();
View chat-service-role.yml
# A role for the service so it can access the tables
ChatServiceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: "ecs-tasks.amazonaws.com"
Action: ['sts:AssumeRole']
View console output
$ time docker-compose build client
Building client
Step 1/9 : FROM node:9 AS build
---> 814364d36f69
Step 2/9 : WORKDIR /srv
---> Using cache
---> 031927a1a5ab
Step 3/9 : ADD package.json .
---> Using cache
---> 9cd95ef4d4ce
View Makefile
run:
docker-compose up -d
build:
docker-compose build client
docker-compose up --no-deps -d client
test:
docker-compose build client
docker-compose build test
View datadog-custom-tracing-node.js
const span = tracer.startSpan('ws');
span.setTag('service.name', 'frontend-ws');
span.setTag('resource.name', 'new message');
// Must call this otherwise asychronous trace spans don't show up under the overall span.
tracer.scopeManager().activate(span);
// Asynchronous code starts here.
// At some point in the future, right before the callback
View docker-compose.yml
version: "3"
networks:
chat:
services:
# Launch the Redis used for syncing messages between copies of the client app
redis:
image: redis
networks:
- chat
View nginx.yml
# This is a Nginx sidecar. This is needed because Consul Connect proxy
# binds to localhost and doesn't accept direct traffic from the public.
# This Nginx container does though and can serve as a proxy to the proxy.
- Name: !Sub ${ServiceName}-nginx
Image: nginx
EntryPoint:
- '/bin/sh'
- '-c'
Command:
- >