Skip to content

Commit

Permalink
Update Dockerfile and devcontainer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
0GiS0 committed Feb 22, 2024
1 parent a0ca33f commit 9f033a1
Show file tree
Hide file tree
Showing 9 changed files with 1,629 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0
FROM mcr.microsoft.com/devcontainers/dotnet:8.0

# Install SQL Tools: SQLPackage and sqlcmd
COPY mssql/installSQLtools.sh installSQLtools.sh
Expand All @@ -10,4 +10,4 @@ RUN bash ./installSQLtools.sh \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
14 changes: 14 additions & 0 deletions .devcontainer/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true

- name: Loki
type: loki
access: proxy
url: http://loki:3100
61 changes: 40 additions & 21 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,70 @@
"workbench.colorTheme": "Visual Studio Light",
"mssql.connections": [
{
"server": "localhost,1433",
"server": "db,1433",
"database": "",
"authenticationType": "SqlLogin",
"user": "sa",
"password": "P@ssword",
"emptyPasswordInput": false,
"savePassword": false,
"profileName": "mssql-container"
"profileName": "mssql-container",
"trustServerCertificate": true
}
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-mssql.mssql",
"humao.rest-client",
"hashicorp.terraform"
"hashicorp.terraform",
"ms-azuretools.vscode-docker",
"redhat.vscode-yaml",
"GitHub.copilot",
"GitHub.copilot-chat"
]
}
},
"remoteEnv": {
"ConnectionStrings__DefaultConnection": "Server=localhost,1433;Initial Catalog=heroes;Persist Security Info=False;User ID=sa;Password=P@ssword;TrustServerCertificate=True"
"ConnectionStrings__DefaultConnection": "Server=db,1433;Initial Catalog=heroes;Persist Security Info=False;User ID=sa;Password=P@ssword;TrustServerCertificate=True"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
5010
5010,
16686,
9090,
3000
],
// "portsAttributes": {
// "5010": {
// "protocol": "http"
// }
// },
"portsAttributes": {
"5010": {
"protocol": "http",
"label": "Tour of Heroes API"
},
"16686": {
"protocol": "http",
"label": "Jaeger UI"
},
"9090":{
"label": "Prometheus",
"protocol": "http"
},
"3000":{
"label": "Grafana",
"protocol": "http"
}
},
// postCreateCommand.sh parameters: $1=SA password, $2=dacpac path, $3=sql script(s) path
"postCreateCommand": "bash .devcontainer/mssql/postCreateCommand.sh 'P@ssword' './bin/Debug/' './.devcontainer/mssql/'",
"postCreateCommand": "dotnet dev-certs https --trust && bash .devcontainer/mssql/postCreateCommand.sh 'P@ssword' './bin/Debug/' './.devcontainer/mssql/'",
"features": {
// "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
// "ghcr.io/devcontainers-contrib/features/terraform-asdf:2": {
// "version": "latest"
// },
// "ghcr.io/devcontainers-contrib/features/terrascan:1": {
// "version": "latest"
// },
// "ghcr.io/devcontainers/features/azure-cli:1": {
// "version": "latest"
// }
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/devcontainers-contrib/features/terraform-asdf:2": {
"version": "latest"
},
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest"
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
110 changes: 91 additions & 19 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,104 @@
version: '3'
version: "3.8"

services:
app:
build:

build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
# user: root

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: mcr.microsoft.com/mssql/server:2019-latest
networks:
- observability
environment:
OTEL_SERVICE_NAME: tour-of-heroes-api
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
ports:
- "5010:5010"

db:
image: mcr.microsoft.com/azure-sql-edge
restart: unless-stopped
environment:
SA_PASSWORD: P@ssword
ACCEPT_EULA: Y
networks:
- observability

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686" # Jaeger UI
command: --query.ui-config=/etc/jaeger/jaeger-ui.json --collector.otlp.enabled=true --prometheus.server-url=http://prometheus:9090 --prometheus.query.support-spanmetrics-connector=true
environment:
METRICS_STORAGE_TYPE: "prometheus"
PROMETHEUS_QUERY_NORMALIZE_CALLS: true
PROMETHEUS_QUERY_NORMALIZE_DURATION: true
volumes:
- "./jaeger-ui.json:/etc/jaeger/jaeger-ui.json"
networks:
- observability

prometheus:
image: prom/prometheus
ports:
- "9090:9090"
networks:
- observability
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml

loki:
image: grafana/loki:latest
command: -config.file=/mnt/config/loki-config.yml
ports:
- "3100:3100"
networks:
- observability
volumes:
- ./loki-config.yml:/mnt/config/loki-config.yml

grafana:
image: grafana/grafana
ports:
- "3000:3000"
environment:
GF_AUTH_ANONYMOUS_ENABLED: true
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_DISABLE_LOGIN_FORM: true
volumes:
- ./grafana.ini:/etc/grafana/grafana.ini
- ./datasource.yml:/etc/grafana/provisioning/datasources/datasource.yaml
networks:
- observability

# https://opentelemetry.io/docs/collector/installation/
otel-collector:
image: otel/opentelemetry-collector-contrib:0.91.0
command: --config /etc/otelcol/otel-collector-config.yml
volumes:
- ./otel-collector-config.yml:/etc/otelcol/otel-collector-config.yml
ports:
- "4317:4317"
networks:
- observability

fake-calls:
image: alpine/curl:latest
entrypoint:
- /bin/sh
- -c
- |
sleep 5
while true; do
curl -s "http://app:5001/api/hero" || true
sleep 0.5
done
networks:
- observability
depends_on:
- app

# Add "forwardPorts": ["1433"] to **devcontainer.json** to forward MSSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
networks:
observability:
Loading

0 comments on commit 9f033a1

Please sign in to comment.