Skip to content

Commit

Permalink
feat(docker): added full containerization and dynamic environment var…
Browse files Browse the repository at this point in the history
…iables via .env file (commented in gitignore on purpose)

feat(csharpier): added csharpier pre-commit hooks with Husky
  • Loading branch information
mezdelex committed Nov 10, 2024
1 parent 989fd46 commit 8fb68fd
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 367 deletions.
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"husky": {
"version": "0.7.1",
"commands": [
"husky"
],
"rollForward": false
}
}
}
231 changes: 0 additions & 231 deletions .editorconfig

This file was deleted.

3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE=cleantemplate
USERNAME=mezdelex
PASSWORD=LapGMhZn55d3omG2jlLZ
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,6 @@ $RECYCLE.BIN/

# Containers
.containers

# Environment
# .env
10 changes: 10 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tasks": [
{
"name": "Run csharpier",
"command": "dotnet",
"args": ["csharpier", "${staged}"],
"include": ["**/*.cs"]
}
]
}
58 changes: 38 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
services:
sqlserver:
image: mcr.microsoft.com/mssql/server

environment:
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=LapGMhZn55d3omG2jlLZ
ports:
- "1433:1433"
restart: always
volumes:
- .containers/ddbb/mssqlserver/data:/var/opt/mssql/data
- .containers/ddbb/mssqlserver/logs:/var/opt/mssql/log

rabbitmq:
image: rabbitmq:management

environment:
RABBITMQ_DEFAULT_USER: mezdelex
RABBITMQ_DEFAULT_PASS: LapGMhZn55d3omG2jlLZ
hostname: rabbitmq
RABBITMQ_DEFAULT_USER: ${USERNAME}
RABBITMQ_DEFAULT_PASS: ${PASSWORD}
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 30s
retries: 3
ports:
# AMQP protocol port
- 5672:5672
# HTTP management UI
- 15672:15672
restart: always
volumes:
Expand All @@ -31,9 +19,39 @@ services:

redis:
image: redis

ports:
- "6379:6379"
volumes:
- .containers/cache/redis/data:/data
- .containers/cache/redis/config/redis.conf:/usr/local/etc/redis/redis.conf

sqlserver:
image: mcr.microsoft.com/mssql/server
environment:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ${PASSWORD}
ports:
- "1433:1433"
restart: always
volumes:
- .containers/ddbb/mssqlserver/data:/var/opt/mssql/data
- .containers/ddbb/mssqlserver/logs:/var/opt/mssql/log

webapi:
build:
context: ./src
dockerfile: Dockerfile
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_started
sqlserver:
condition: service_started
environment:
ASPNETCORE_HTTP_PORTS: 8000
DATABASE: ${DATABASE}
USERNAME: ${USERNAME}
PASSWORD: ${PASSWORD}
ports:
- "8000:8000"
14 changes: 14 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG PASSWORD
WORKDIR /app
COPY . .
RUN dotnet restore ./WebApi/WebApi.csproj
RUN dotnet build ./WebApi/WebApi.csproj -c Release
RUN dotnet publish ./WebApi/WebApi.csproj -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/out .
EXPOSE 8000 8001

ENTRYPOINT ["dotnet", "WebApi.dll"]
Loading

0 comments on commit 8fb68fd

Please sign in to comment.