Skip to content

Commit 3c11a84

Browse files
committed
installing emulator cert and setting up the app config
1 parent 91db689 commit 3c11a84

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
"ionide.ionide-paket",
2323
"github.vscode-pull-request-github",
2424
"paolodellepiane.fantomas-fmt",
25-
"ms-azuretools.vscode-cosmosdb"
25+
"ms-azuretools.vscode-cosmosdb",
26+
"ms-azuretools.vscode-docker"
2627
],
2728

2829
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2930
// "forwardPorts": [],
3031

3132
// Use 'postCreateCommand' to run commands after the container is created.
32-
"postCreateCommand": "dotnet tool restore && dotnet restore && ./.devcontainer/start.sh",
33+
"postCreateCommand": "dotnet tool restore && dotnet restore",
34+
35+
"postStartCommand": "./.devcontainer/start.sh",
3336

3437
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
3538
"remoteUser": "vscode"

.devcontainer/docker-compose.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ version: '3'
22

33
services:
44
app:
5-
build:
5+
build:
66
context: .
77
dockerfile: Dockerfile
88
args:
9-
USER_UID: 1000
10-
USER_GID: 1000
11-
VARIANT: "6.0"
9+
USER_UID: 1000
10+
USER_GID: 1000
11+
VARIANT: "6.0"
1212

1313
init: true
1414
volumes:
15-
- /var/run/docker.sock:/var/run/docker-host.sock
16-
- ..:/workspace:cached
15+
- /var/run/docker.sock:/var/run/docker-host.sock
16+
- ..:/workspace:cached
1717

1818
entrypoint: /usr/local/share/docker-init.sh
1919
command: sleep infinity
2020
environment:
21-
# These names aren't special - they're just used in the Node app to configure the CosmosClient
22-
COSMOS__ENDPOINT: https://cosmos:8081
2321
# This is the publicly documented emulator key
2422
COSMOS__KEY: 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=='
2523

2624
network_mode: service:cosmos
25+
2726
cosmos:
27+
container_name: cosmos
2828
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
2929
mem_limit: 3g
3030
cpu_count: 2
3131
environment:
32-
AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 10
33-
AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: "true"
32+
AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 10
33+
AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: "true"
3434
volumes:
35-
# Forwards the local Docker socket to the container.
36-
- /var/run/docker.sock:/var/run/docker-host.sock
35+
# Forwards the local Docker socket to the container.
36+
- /var/run/docker.sock:/var/run/docker-host.sock

.devcontainer/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
set -euxo pipefail
44

5+
COSMOS__ENDPOINT=https://$(docker inspect cosmos -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'):8081
6+
57
# Try to get the emulator cert in a loop
68
until sudo curl -ksf "${COSMOS__ENDPOINT}/_explorer/emulator.pem" -o '/usr/local/share/ca-certificates/emulator.crt'; do
79
echo "Downloading cert from $COSMOS__ENDPOINT"
810
sleep 1
911
done
1012

1113
sudo update-ca-certificates
14+
15+
echo '{ "Cosmos": { "EndPoint" : "'$COSMOS__ENDPOINT'" } }' >> ./samples/FSharp.CosmosDb.Samples/appsettings.Development.json

0 commit comments

Comments
 (0)