Skip to content

Commit ff9c79e

Browse files
author
Andrea Scuderi
committed
Update README
1 parent 85ea89f commit ff9c79e

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Before we start, make sure you have these tools installed on your system:
1616

1717
* [Docker](https://docs.docker.com/get-docker/)
1818
* [Visual Studio Code](https://code.visualstudio.com/download)
19-
* [Visual Studio Code Remote - Containers Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
19+
* [Visual Studio Code Dev Containers Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
2020
* [Docker Compose V2](https://docs.docker.com/compose/cli-command/)
2121
* It's also helpful to review the [official guide on configuring VS Code for Swift](https://www.swift.org/documentation/articles/getting-started-with-vscode-swift.html) and install Swift extension.
2222

@@ -74,11 +74,13 @@ Let's make sure you can build and run locally first. Try running the debugger. T
7474
Now, let's tell VS Code how to build our container.
7575

7676
1. Open the command palette (**Cmd+Shift+P** / **Ctrl+Shift+P**).
77-
2. Type and select **"Remote-Containers: Add Development Container Configuration Files..."**.
78-
3. Choose **"Docker from Docker Compose"**.
79-
4. Select **"Default Configuration"**.
80-
5. When prompted to add features, select **"AWS CLI"**.
81-
6. You can also select `.github/dependabot.yml` if you plan to use it.
77+
2. Type and select **"Dev Containers: Add Dev Container Configuration Files..."**.
78+
3. Choose **"Add configuration to workspace"**.
79+
4. Choose **"Docker outside of Docker Compose"**.
80+
5. Select **"latest"**.
81+
6. Select the default options
82+
7. When prompted to add features, select **"AWS CLI"**.
83+
8. You can also select `.github/dependabot.yml` if you plan to use it.
8284

8385
This will create a `.devcontainer` folder with a `devcontainer.json` and `docker-compose.yml` file.
8486

@@ -176,6 +178,9 @@ services:
176178
security_opt:
177179
- seccomp:unconfined
178180

181+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
182+
# (Adding the "ports" property to this file will not forward from a Codespace.)
183+
179184
# Add the localstack service
180185
localstack:
181186
image: localstack/localstack
@@ -200,7 +205,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
200205
Now for the magic.
201206

202207
1. Open the command palette (**Cmd+Shift+P** / **Ctrl+Shift+P**).
203-
2. Type and select **"Remote-Containers: Rebuild and Reopen in Container"**.
208+
2. Type and select **"Dev Containers: Rebuild and Reopen in Container"**.
204209

205210
VS Code will now build your `Dockerfile`, start the `docker-compose` services (your Swift app and LocalStack), and reload the window, connecting you *inside* the `app` container. You'll know it worked when the bottom-left corner of VS Code shows "Dev Container: ...".
206211

@@ -209,8 +214,9 @@ VS Code will now build your `Dockerfile`, start the `docker-compose` services (y
209214
Remember that old `launch.json` from Step 5? It's pointing to your *local* machine's paths, which don't exist inside the container. Let's fix it.
210215

211216
1. You can delete the old `.vscode/launch.json` file if you want, or just let this next step overwrite it.
212-
2. Open the command palette (**Cmd+Shift+P** / **Ctrl+Shift+P**).
213-
3. Type and select **"Swift: Generate Launch Configuration"**.
217+
2. Select the `Package.swift` file in the Explorer to make it the active file.
218+
3. Open the command palette (**Cmd+Shift+P** / **Ctrl+Shift+P**).
219+
4. Type and select **"Swift: Generate Launch Configuration"**.
214220

215221
This will create a *new* `launch.json` with the correct *container* paths (e.g., `/workspaces/SwiftInDevContainer/.build/debug/SwiftInDevContainer`).
216222

@@ -224,19 +230,18 @@ First, update your `Package.swift` to include `soto-dynamodb`:
224230

225231
```swift
226232
// swift-tools-version: 6.2
233+
227234
import PackageDescription
228235
229236
let package = Package(
230237
name: "SwiftInDevContainer",
231238
dependencies: [
232-
// Add Soto
233239
.package(url: "https://github.com/soto-project/soto.git", from: "7.0.0"),
234240
],
235241
targets: [
236242
.executableTarget(
237243
name: "SwiftInDevContainer",
238244
dependencies: [
239-
// Add the DynamoDB product
240245
.product(name: "SotoDynamoDB", package: "soto"),
241246
]
242247
),
@@ -282,12 +287,12 @@ Create a `Makefile` in the root of your project:
282287

283288
```makefile
284289
localstack_create_dynamo_db_table:
285-
aws --endpoint-url=http://localstack:4566 dynamodb create-table \
286-
--table-name Breeze \
287-
--attribute-definitions AttributeName=itemKey,AttributeType=S \
288-
--key-schema AttributeName=itemKey,KeyType=HASH \
289-
--billing-mode PAY_PER_REQUEST \
290-
--region us-east-1
290+
aws --endpoint-url=http://localstack:4566 dynamodb create-table \
291+
--table-name Breeze \
292+
--attribute-definitions AttributeName=itemKey,AttributeType=S \
293+
--key-schema AttributeName=itemKey,KeyType=HASH \
294+
--billing-mode PAY_PER_REQUEST \
295+
--region us-east-1
291296
```
292297

293298
Now, in the VS Code terminal (which is *inside* the container), run the command:

0 commit comments

Comments
 (0)