Skip to content

Commit

Permalink
Add devcontainer setups (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
lakkeger authored Aug 26, 2024
1 parent 5446c0f commit bc0af58
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 1 deletion.
56 changes: 56 additions & 0 deletions .devcontainer/docker-in-docker/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "LocalStack DinD setup",
"image": "mcr.microsoft.com/devcontainers/base:jammy",

"remoteEnv": {
// Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
"LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required for Pro, not processed via template due to security reasons
"LOCALSTACK_API_KEY": "${localEnv:LOCALSTACK_API_KEY}",
// LocalStack configuration: https://docs.localstack.cloud/references/configuration/
"ACTIVATE_PRO": true,
"DEBUG": true,
"LS_LOG": "trace",
"PERSISTENCE": false,
"AWS_ENDPOINT_URL": "http://localhost.localstack.cloud:4566",
"AUTO_LOAD_POD": "",
"ENFORCE_IAM": false,
"AWS_REGION": "us-east-1",
"AWS_DEFAULT_REGION": "us-east-1",
"IMAGE_NAME": "localstack/localstack-pro:latest",
"LOCALSTACK_VOLUME_DIR": "/data"
},

// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
"version": "latest",
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
},
"ghcr.io/devcontainers/features/aws-cli:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
}
},

// 👇 Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "type localstack; true && localstack start -d || true",
"mounts": [
{
// to persist build data and images
"source": "dind-var-lib-docker",
"target": "/var/lib/docker",
"type": "volume"
},
{
"source": "./.volume",
"target": "/data",
"type": "bind",
"consistency": "cached"
}
]
}
15 changes: 15 additions & 0 deletions .devcontainer/docker-outside-of-docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-} # required for Pro, not processed via template due to security reasons
LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:-}
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
ACTIVATE_PRO=true
DEBUG=true
LS_LOG=trace
PERSISTENCE=false
AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
LOCALSTACK_HOST=localhost.localstack.cloud:4566
AUTO_LOAD_POD=
ENFORCE_IAM=false
AWS_REGION=us-east-1
AWS_DEFAULT_REGION=us-east-1
IMAGE_NAME=localstack/localstack-pro:latest
1 change: 1 addition & 0 deletions .devcontainer/docker-outside-of-docker/.volume/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Keep this folder for DevContainers DooD setup
1 change: 1 addition & 0 deletions .devcontainer/docker-outside-of-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:bookworm
23 changes: 23 additions & 0 deletions .devcontainer/docker-outside-of-docker/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "LocalStack DooD setup",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
"version": "latest",
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
},
"ghcr.io/devcontainers/features/aws-cli:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
}
}
}
43 changes: 43 additions & 0 deletions .devcontainer/docker-outside-of-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.8"

services:
localstack:
container_name: "localstack-main"
image: localstack/localstack-pro:latest # required for Pro
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
env_file:
- .env
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./.volume:/var/lib/localstack"
networks:
ls:
# Set the container IP address in the info subnet
ipv4_address: 10.0.2.20

app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
init: true
env_file:
- .env
dns:
# Set the DNS server to be the LocalStack container
- 10.0.2.20
networks:
- ls

networks:
ls:
ipam:
config:
# Specify the subnet range for IP address allocation
- subnet: 10.0.2.0/24
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package-lock.json
/nosetests.xml

.env
!.devcontainer/**/.env
venv
/.venv*
/.coverage
Expand Down Expand Up @@ -58,4 +59,4 @@ volume/

# lambda packages
lambdas/*/package/
lambdas/*/lambda.zip
lambdas/*/lambda.zip
1 change: 1 addition & 0 deletions .volume/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Keep this folder for DevContainers DinD setup

0 comments on commit bc0af58

Please sign in to comment.