Skip to content

Commit

Permalink
added dynamodb - app fully supports aws
Browse files Browse the repository at this point in the history
  • Loading branch information
marythedev committed Dec 5, 2023
1 parent b27e2d7 commit 6a47132
Show file tree
Hide file tree
Showing 15 changed files with 1,041 additions and 182 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,33 @@ jobs:
#2. Use `install-ci-test` to do it in a single command, see https://docs.npmjs.com/cli/v8/commands/npm-install-ci-test
run: npm install-ci-test

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install node dependencies
# NOTE: we need to install dev dependencies too vs. production only for hurl
run: npm install
- name: Build Containers
run: docker compose up -d
- name: Setup Local AWS Resources
# NOTE: this file needs to be made executable *before* you check into git:
# $ chmod +x ./scripts/local-aws-setup.sh
run: ./scripts/local-aws-setup.sh
- name: Run Hurl Tests
run: npm run test:integration


docker-hub:
name: Build and Push Image to Docker Hub
needs: [lint, dockerfile-lint, unit-tests]
needs: [lint, dockerfile-lint, unit-tests, integration-tests]
runs-on: ubuntu-latest
steps:
# Set up buildx for optimal Docker Builds, see:
Expand All @@ -95,4 +119,4 @@ jobs:
with:
push: true
# Use 3 tags: :latest-commit-sha, :main, and :latest
tags: ${{ env.DOCKERHUB_REPO }}:${{ env.SHA_TAG }}, ${{ env.DOCKERHUB_REPO }}:main, ${{ env.DOCKERHUB_REPO }}:latest
tags: ${{ env.DOCKERHUB_REPO }}:${{ env.SHA_TAG }}, ${{ env.DOCKERHUB_REPO }}:main, ${{ env.DOCKERHUB_REPO }}:latest
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
environment:
- API_URL=http://localhost:8080 # API is running on http://localhost:8080
- HTPASSWD_FILE=tests/.htpasswd # Use Basic Auth (for running tests, CI)
- LOG_LEVEL=${LOG_LEVEL:-info}
- LOG_LEVEL=${LOG_LEVEL:-debug}
- AWS_REGION=us-east-1
# Use the LocalStack endpoint vs. AWS for S3 AWS SDK clients.
# NOTE: we use Docker's internal network to the localstack container
Expand All @@ -19,6 +19,9 @@ services:
# default to 'fragments' as the name, unless something else is defined in the env.
- AWS_S3_BUCKET_NAME=${AWS_S3_BUCKET_NAME:-fragments}
- AWS_DYNAMODB_TABLE_NAME=${AWS_DYNAMODB_TABLE_NAME:-fragments}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
# Ports to publish
ports:
- '8080:8080'
Expand All @@ -30,7 +33,7 @@ services:
- '8000:8000'
# Run the database in memory, see:
# https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.UsageNotes.html
command: ['-jar', 'DynamoDBLocal.jar', '-inMemory']
command: ['-jar', 'DynamoDBLocal.jar', '-inMemory', '-sharedDb']

# LocalStack for S3, see https://docs.localstack.cloud/get-started/#docker-compose
# Interact via awscli-local, see https://docs.localstack.cloud/integrations/aws-cli/#installation
Expand Down
273 changes: 148 additions & 125 deletions fragments-definition.json
Original file line number Diff line number Diff line change
@@ -1,127 +1,150 @@
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::390240750368:role/LabRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/fragments-task",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": [],
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"command": [],
"linuxParameters": null,
"cpu": 256,
"environment": [
{
"name": "PORT",
"value": "8080"
}, {
"name": "AWS_S3_BUCKET_NAME",
"value": "maria.dmytrenko-fragments"
}
],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": 512,
"volumesFrom": [],
"stopTimeout": null,
"image": "mdmytrenko/fragments:latest",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": [],
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "fragments"
}
],
"placementConstraints": [],
"memory": "512",
"taskRoleArn": "arn:aws:iam::390240750368:role/LabRole",
"compatibilities": [
"EC2",
"FARGATE"
],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:390240750368:task-definition/fragments-task:2",
"family": "fragments-task",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::390240750368:role/LabRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/fragments-task",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.task-eni"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"runtimePlatform": null,
"cpu": "256",
"revision": 2,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
"entryPoint": null,
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"command": null,
"linuxParameters": null,
"cpu": 256,
"environment": [
{
"name": "AWS_S3_BUCKET_NAME",
"value": "maria.dmytrenko-fragments"
},
{
"name": "AWS_DYNAMODB_TABLE_NAME",
"value": "fragments"
},
{
"name": "PORT",
"value": "8080"
}
],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": 512,
"volumesFrom": [],
"stopTimeout": null,
"image": "390240750368.dkr.ecr.us-east-1.amazonaws.com/fragments:v0.9.0",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "fragments"
}
],
"placementConstraints": [],
"memory": "512",
"taskRoleArn": "arn:aws:iam::390240750368:role/LabRole",
"compatibilities": [
"EC2",
"FARGATE"
],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:390240750368:task-definition/fragments-task:5",
"family": "fragments-task",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.task-eni"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"runtimePlatform": null,
"cpu": "256",
"revision": 5,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
Loading

0 comments on commit 6a47132

Please sign in to comment.