Skip to content

Commit bc0af58

Browse files
authored
Add devcontainer setups (#35)
1 parent 5446c0f commit bc0af58

File tree

8 files changed

+142
-1
lines changed

8 files changed

+142
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "LocalStack DinD setup",
3+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
4+
5+
"remoteEnv": {
6+
// Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
7+
"LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required for Pro, not processed via template due to security reasons
8+
"LOCALSTACK_API_KEY": "${localEnv:LOCALSTACK_API_KEY}",
9+
// LocalStack configuration: https://docs.localstack.cloud/references/configuration/
10+
"ACTIVATE_PRO": true,
11+
"DEBUG": true,
12+
"LS_LOG": "trace",
13+
"PERSISTENCE": false,
14+
"AWS_ENDPOINT_URL": "http://localhost.localstack.cloud:4566",
15+
"AUTO_LOAD_POD": "",
16+
"ENFORCE_IAM": false,
17+
"AWS_REGION": "us-east-1",
18+
"AWS_DEFAULT_REGION": "us-east-1",
19+
"IMAGE_NAME": "localstack/localstack-pro:latest",
20+
"LOCALSTACK_VOLUME_DIR": "/data"
21+
},
22+
23+
// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
24+
"features": {
25+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
26+
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
27+
"version": "latest",
28+
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
29+
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
30+
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
31+
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
32+
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
33+
},
34+
"ghcr.io/devcontainers/features/aws-cli:1": {},
35+
"ghcr.io/devcontainers/features/python:1": {
36+
"version": "3.11"
37+
}
38+
},
39+
40+
// 👇 Use 'postCreateCommand' to run commands after the container is created.
41+
"postCreateCommand": "type localstack; true && localstack start -d || true",
42+
"mounts": [
43+
{
44+
// to persist build data and images
45+
"source": "dind-var-lib-docker",
46+
"target": "/var/lib/docker",
47+
"type": "volume"
48+
},
49+
{
50+
"source": "./.volume",
51+
"target": "/data",
52+
"type": "bind",
53+
"consistency": "cached"
54+
}
55+
]
56+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
2+
LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-} # required for Pro, not processed via template due to security reasons
3+
LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:-}
4+
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
5+
ACTIVATE_PRO=true
6+
DEBUG=true
7+
LS_LOG=trace
8+
PERSISTENCE=false
9+
AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
10+
LOCALSTACK_HOST=localhost.localstack.cloud:4566
11+
AUTO_LOAD_POD=
12+
ENFORCE_IAM=false
13+
AWS_REGION=us-east-1
14+
AWS_DEFAULT_REGION=us-east-1
15+
IMAGE_NAME=localstack/localstack-pro:latest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Keep this folder for DevContainers DooD setup
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/devcontainers/base:bookworm
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "LocalStack DooD setup",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
6+
7+
// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
8+
"features": {
9+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
10+
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
11+
"version": "latest",
12+
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
13+
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
14+
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
15+
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
16+
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
17+
},
18+
"ghcr.io/devcontainers/features/aws-cli:1": {},
19+
"ghcr.io/devcontainers/features/python:1": {
20+
"version": "3.11"
21+
}
22+
}
23+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: "3.8"
2+
3+
services:
4+
localstack:
5+
container_name: "localstack-main"
6+
image: localstack/localstack-pro:latest # required for Pro
7+
ports:
8+
- "127.0.0.1:4566:4566" # LocalStack Gateway
9+
- "127.0.0.1:4510-4559:4510-4559" # external services port range
10+
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
11+
env_file:
12+
- .env
13+
volumes:
14+
- "/var/run/docker.sock:/var/run/docker.sock"
15+
- "./.volume:/var/lib/localstack"
16+
networks:
17+
ls:
18+
# Set the container IP address in the info subnet
19+
ipv4_address: 10.0.2.20
20+
21+
app:
22+
build:
23+
context: .
24+
dockerfile: Dockerfile
25+
volumes:
26+
- ../..:/workspaces:cached
27+
# Overrides default command so things don't shut down after the process ends.
28+
command: sleep infinity
29+
init: true
30+
env_file:
31+
- .env
32+
dns:
33+
# Set the DNS server to be the LocalStack container
34+
- 10.0.2.20
35+
networks:
36+
- ls
37+
38+
networks:
39+
ls:
40+
ipam:
41+
config:
42+
# Specify the subnet range for IP address allocation
43+
- subnet: 10.0.2.0/24

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package-lock.json
1111
/nosetests.xml
1212

1313
.env
14+
!.devcontainer/**/.env
1415
venv
1516
/.venv*
1617
/.coverage
@@ -58,4 +59,4 @@ volume/
5859

5960
# lambda packages
6061
lambdas/*/package/
61-
lambdas/*/lambda.zip
62+
lambdas/*/lambda.zip

.volume/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Keep this folder for DevContainers DinD setup

0 commit comments

Comments
 (0)