Skip to content

Commit 671ad87

Browse files
author
Andrea Scuderi
committed
Update Dev Container with ubuntu swift:6.2.0 and localstack
1 parent 5a8807a commit 671ad87

File tree

8 files changed

+86
-26
lines changed

8 files changed

+86
-26
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM swift:6.2.0
2+
3+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends make git

.devcontainer/devcontainer.json

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-outside-of-docker-compose
13
{
2-
"name": "Swift",
3-
"image": "swift:6.2.0",
4-
"features": {
5-
"ghcr.io/devcontainers/features/common-utils:2": {
6-
"installZsh": "false",
7-
"username": "vscode",
8-
"upgradePackages": "false"
9-
},
10-
"ghcr.io/devcontainers/features/git:1": {
11-
"version": "os-provided",
12-
"ppa": "false"
13-
}
14-
},
15-
"runArgs": [
16-
"--cap-add=SYS_PTRACE",
17-
"--security-opt",
18-
"seccomp=unconfined"
19-
],
20-
// Configure tool-specific properties.
4+
"name": "Docker from Docker Compose",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Use this environment variable if you need to bind mount your local source code into a new container.
10+
"remoteEnv": {
11+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
12+
},
13+
14+
"features": {
15+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
16+
"version": "latest",
17+
"enableNonRootDocker": "true",
18+
"moby": "true"
19+
},
20+
"ghcr.io/devcontainers/features/aws-cli:1": {}
21+
},
22+
// Configure tool-specific properties.
2123
"customizations": {
2224
// Configure properties specific to VS Code.
2325
"vscode": {
@@ -31,9 +33,12 @@
3133
]
3234
}
3335
},
34-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
35-
// "forwardPorts": [],
36+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
37+
// "forwardPorts": [],
38+
39+
// Use 'postCreateCommand' to run commands after the container is created.
40+
// "postCreateCommand": "docker --version",
3641

37-
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
38-
"remoteUser": "vscode"
42+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
43+
// "remoteUser": "vscode"
3944
}

.devcontainer/docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
9+
volumes:
10+
# Forwards the local Docker socket to the container.
11+
- /var/run/docker.sock:/var/run/docker-host.sock
12+
# Update this to wherever you want VS Code to mount the folder of your project
13+
- ../..:/workspaces:cached
14+
15+
# Overrides default command so things don't shut down after the process ends.
16+
entrypoint: /usr/local/share/docker-init.sh
17+
depends_on:
18+
- localstack
19+
environment:
20+
- LOCALSTACK_ENDPOINT=http://localstack:4566
21+
- AWS_ACCESS_KEY_ID=test
22+
- AWS_SECRET_ACCESS_KEY=test
23+
- AWS_REGION=us-east-1
24+
command: sleep infinity
25+
26+
# Uncomment the next four lines if you will use a ptrace-based debuggers like C++, Go, and Rust.
27+
cap_add:
28+
- SYS_PTRACE
29+
security_opt:
30+
- seccomp:unconfined
31+
32+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
33+
# (Adding the "ports" property to this file will not forward from a Codespace.)
34+
35+
localstack:
36+
image: localstack/localstack

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ localstack:
2121
docker run -it --rm -p "4566:4566" localstack/localstack
2222

2323
local_setup_dynamo_db:
24-
aws --endpoint-url=http://localhost:4566 dynamodb create-table \
24+
aws --endpoint-url=http://localstack:4566 dynamodb create-table \
2525
--table-name Breeze \
2626
--attribute-definitions AttributeName=itemKey,AttributeType=S \
2727
--key-schema AttributeName=itemKey,KeyType=HASH \

Sources/BreezeDynamoDBService/BreezeDynamoDBService.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public struct BreezeDynamoDBService: BreezeDynamoDBServing {
5151
logger.info("region: \(config.region)")
5252
logger.info("tableName: \(config.tableName)")
5353
logger.info("keyName: \(config.keyName)")
54+
if config.endpoint != nil {
55+
logger.info("endpoint: \(config.endpoint!)")
56+
}
5457
self.logger = logger
5558

5659
let timeout = HTTPClient.Configuration.Timeout(

Sources/BreezeLambdaItemAPI/BreezeLambdaItemAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct APIConfiguration: APIConfiguring {
5454
/// You can change the region, table name, key name, and endpoint as needed for your application.
5555
/// Remove the endpoint for production use.
5656
func getConfig() throws -> BreezeDynamoDBConfig {
57-
BreezeDynamoDBConfig(region: .useast1, tableName: "Breeze", keyName: "itemKey", endpoint: "http://127.0.0.1:4566")
57+
BreezeDynamoDBConfig(region: .useast1, tableName: "Breeze", keyName: "itemKey", endpoint: "http://localstack:4566")
5858
}
5959
}
6060

Tests/BreezeLambdaAPITests/BreezeLambdaAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct APIConfiguration: APIConfiguring {
2626
.list
2727
}
2828
func getConfig() throws -> BreezeDynamoDBConfig {
29-
BreezeDynamoDBConfig(region: .useast1, tableName: "Breeze", keyName: "itemKey", endpoint: "http://127.0.0.1:4566")
29+
BreezeDynamoDBConfig(region: .useast1, tableName: "Breeze", keyName: "itemKey", endpoint: "http://localstack:4566")
3030
}
3131
}
3232

0 commit comments

Comments
 (0)