Skip to content

Commit

Permalink
Prepare infra for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardin08 committed May 20, 2024
1 parent a6a8101 commit 0e809ca
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.sonarqube
[oO]bj
[bB]in
29 changes: 11 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
# STAGE 1: Build Environment
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
WORKDIR /src

ARG NUGET_API_KEY

# Copy the project files first for better layer caching (if only code changes)
COPY . ./

# Add the custom NuGet source
RUN dotnet nuget add source https://nuget.pkg.github.com/trumpee/index.json --name github --username trumpee --password $NUGET_API_KEY --store-password-in-clear-text
RUN dotnet nuget add source https://nuget.pkg.github.com/trumpee/index.json \
--name github \
--username trumpee \
--password $NUGET_API_KEY \
--store-password-in-clear-text

# Restore NuGet packages from both sources
RUN dotnet restore Gateway.sln --source "https://api.nuget.org/v3/index.json" --source "https://nuget.pkg.github.com/trumpee/index.json"
RUN dotnet restore Gateway.sln \
--source "https://api.nuget.org/v3/index.json" \
--source "https://nuget.pkg.github.com/trumpee/index.json"

# Build the solution
RUN dotnet build Gateway.sln -c Release
RUN dotnet build Gateway.sln -c Debug
RUN dotnet publish ./src/Api/Api.csproj -c Debug -o /app

# Publish the Api project only (assuming this is the main entry point)
RUN dotnet publish ./src/Api/Api.csproj -c Release -o /app

# STAGE 2: Runtime Environment
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
WORKDIR /app
COPY --from=build-env /app .

# Expose the port your application listens on (replace 80 if needed)
EXPOSE 80

# Define the entry point for your application
ENTRYPOINT ["dotnet", "Api.dll"]
29 changes: 0 additions & 29 deletions docker-compose.yml

This file was deleted.

28 changes: 0 additions & 28 deletions infra-only-docker-compose.yml

This file was deleted.

50 changes: 50 additions & 0 deletions sonarqube-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"
services:
sonarqube:
image: sonarqube:community
container_name: sonarqube
depends_on:
- db
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_logs:/opt/sonarqube/logs
ports:
- "9000:9000"
db:
image: postgres:13
hostname: postgresql
container_name: postgresql
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
POSTGRES_DB: sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data

sonar-scanner:
container_name: sonar-scanner
image: newtmitch/sonar-scanner
networks:
- sonarnet
volumes:
- ./:/usr/src
depends_on:
- sonarqube

networks:
sonarnet:

volumes:
sonarqube_conf:
sonarqube_data:
sonarqube_logs:
sonarqube_extensions:
sonarqube_bundled-plugins:
postgresql:
postgresql_data:
10 changes: 5 additions & 5 deletions src/Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"Logging": {
"LogLevel": {
"Default": "Error",
"Microsoft.AspNetCore": "Error",
"Default": "Trace",
"Microsoft.AspNetCore": "Trace",
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None"
}
},
"AllowedHosts": "*",
"MongoDb": {
"DatabaseName": "trumpee",
"ConnectionString": "mongodb://root:password@localhost:23001/"
"ConnectionString": "mongodb://root:password@trumpee_mongodb:27017/"
},
"MassTransit": {
"Transport": {
"Host": "127.0.0.1",
"Host": "trumpee_rabbitmq",
"VHost": "/",
"Username": "guest",
"Password": "guest",
"Port": 23501
"Port": 5672
}
}
}

0 comments on commit 0e809ca

Please sign in to comment.