Skip to content

Commit

Permalink
Add docker / docker compose support
Browse files Browse the repository at this point in the history
  • Loading branch information
BlairMcc committed Oct 9, 2021
1 parent 41bbd7f commit 923240b
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
22 changes: 22 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["api/api.csproj", "api/"]
RUN dotnet restore "api/api.csproj"
COPY . .
WORKDIR "/src/api"
RUN dotnet build "api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "api.dll"]
15 changes: 15 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>a011acee-c112-49cf-8af7-6f2fc209a8d4</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>api</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.4'

services:
api:
image: ${DOCKER_REGISTRY-}api
build:
context: .
dockerfile: api/Dockerfile
ports:
- 8081:80
depends_on:
- sqlserver
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
restart: unless-stopped
ports:
- 1431:1433
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -b -o /dev/null
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
#volumes:
# - product_data:/var/opt/mssql
environment:
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=P@ssword1234
- MSSQL_PID=Developer
#postgres:
# image: postgres:14.0-alpine
# healthcheck:
# test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ]
# timeout: 45s
# interval: 10s
# retries: 10
# restart: always
# environment:
# - POSTGRES_USER=root
# - POSTGRES_PASSWORD=password
# - APP_DB_USER=docker
# - APP_DB_PASS=docker
# - APP_DB_NAME=docker
# #volumes:
# # - ./db:/docker-entrypoint-initdb.d/
# ports:
# - 5432:5432

0 comments on commit 923240b

Please sign in to comment.