Skip to content
Thang Chung edited this page May 24, 2020 · 1 revision

Run dapr on docker and docker-compose (not working correctly now)

Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build

RUN wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash

RUN wget -q https://github.com/dapr/dapr/releases/download/v0.7.0/daprd_linux_amd64.tar.gz -O daprd_linux_amd64.tar.gz --show-progress \
  && tar -xvzf daprd_linux_amd64.tar.gz \
  && rm daprd_linux_amd64.tar.gz \
  && mv daprd /usr/local/bin

RUN dapr --version
RUN dapr init --network practical-dapr
RUN daprd -version

WORKDIR /src
COPY . .

docker-compose.yaml

version: "3.7"

services:

  inventory-api:
    image: ${REGISTRY:-vndg}/inventory-api:${TAG:-latest}
    restart: unless-stopped
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - 5015:5015
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    entrypoint:
      - dapr
      - run
      - --app-id
      - inventoryapi
      - --app-port
      - "5005"
      - --port
      - "5015"
      - dotnet
      - run
      - dotnet
      - --
      - -p
      - src/Inventory/CoolStore.InventoryApi/CoolStore.InventoryApi.csproj
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - practical-dapr
    depends_on:
      - sqlserver

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2017-latest
    restart: unless-stopped
    ports:
      - 1433:1433
    environment:
      SA_PASSWORD: "P@ssw0rd"
      ACCEPT_EULA: "Y"
    networks:
      - practical-dapr

networks:
  practical-dapr:
    name: practical-dapr-network
Clone this wiki locally