docker composes
This commit is contained in:
parent
71c4f5022c
commit
a90cdc08b8
9 changed files with 88 additions and 54 deletions
14
.env.sample
14
.env.sample
|
|
@ -1,7 +1,9 @@
|
|||
APP_NAME=Yavsc
|
||||
YAVSC_CONNECTION_HOST=localhost
|
||||
YAVSC_CONNECTION_PORT=5432
|
||||
YAVSC_CONNECTION_DATABASE=Yavsc
|
||||
YAVSC_CONNECTION_USERNAME=Yavsc
|
||||
YAVSC_CONNECTION_PASSWORD=lame-YAVSC_CONNECTION_PASSWORD
|
||||
DESTDIR=/srv/www/Yavsc
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB=yavsc
|
||||
POSTGRES_USER=yavsc
|
||||
POSTGRES_PASSWORD=lame-YAVSC_CONNECTION_PASSWORD
|
||||
DESTDIR=/srv/www/yavsc
|
||||
|
||||
ASPNETCORE_ConnectionStrings__YavscConnection=Server=$POSTGRES_HOST;Port=$POSTGRES_PORT;Database=$POSTGRES_DB;Username=$POSTGRES_USER;Password=$POSTGRES_PASSWORD;
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -53,4 +53,5 @@ binaries/
|
|||
build/
|
||||
src/*/Blog-Dev/
|
||||
*.mp4
|
||||
src/Yavsc.Org/data/
|
||||
|
||||
|
|
|
|||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -5,6 +5,7 @@
|
|||
"appsettings",
|
||||
"asciidoctor",
|
||||
"Cratie",
|
||||
"DESTDIR",
|
||||
"Newtonsoft",
|
||||
"Npgsql",
|
||||
"Yavsc"
|
||||
|
|
|
|||
54
Dockerfile
54
Dockerfile
|
|
@ -1,32 +1,30 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Learn about building .NET container images:
|
||||
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
# Build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["/src", "/src"]
|
||||
COPY "Directory.Packages.props" "Directory.Packages.props"
|
||||
COPY . .
|
||||
RUN dotnet publish src/Yavsc/Yavsc.csproj -c Release -o /app/publish
|
||||
|
||||
RUN dotnet nuget add source https://isn.pschneider.fr/v3/index.json --allow-insecure-connections
|
||||
|
||||
# Just to see if two lines above work
|
||||
RUN dotnet nuget list source
|
||||
|
||||
RUN dotnet restore "/src/Yavsc/Yavsc.csproj"
|
||||
|
||||
# Copy source code and publish app
|
||||
|
||||
WORKDIR "/src/Yavsc"
|
||||
RUN dotnet build "Yavsc.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Yavsc.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
# Runtime stage
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# Variables d'environnement avec valeurs par défaut
|
||||
ARG POSTGRES_HOST=localhost
|
||||
ARG POSTGRES_PORT=5432
|
||||
ARG POSTGRES_DB=yavsc
|
||||
ARG POSTGRES_USER=yavsc
|
||||
ARG POSTGRES_PASSWORD
|
||||
|
||||
ENV POSTGRES_HOST=${POSTGRES_HOST}
|
||||
ENV POSTGRES_PORT=${POSTGRES_PORT}
|
||||
ENV POSTGRES_DB=${POSTGRES_DB}
|
||||
ENV POSTGRES_USER=${POSTGRES_USER}
|
||||
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
||||
# Chaîne de connexion construite depuis les variables
|
||||
ENV ConnectionStrings__DefaultConnection=\
|
||||
"Host=${POSTGRES_HOST};Port=${POSTGRES_PORT};Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}"
|
||||
|
||||
COPY --from=build /app/publish .
|
||||
EXPOSE 5000
|
||||
ENTRYPOINT ["dotnet", "Yavsc.dll"]
|
||||
|
|
|
|||
7
Makefile
7
Makefile
|
|
@ -40,4 +40,11 @@ install: $(DESTDIR)
|
|||
docker-image:
|
||||
docker build .
|
||||
|
||||
docker-build:
|
||||
docker compose up --build
|
||||
|
||||
docker-run:
|
||||
docker run -d -p 5000:5000 --name yavsc yavsc
|
||||
|
||||
|
||||
.PHONY:
|
||||
|
|
|
|||
24
docker-compose.yaml
Normal file
24
docker-compose.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
env_file: .env
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_PORT: ${POSTGRES_PORT}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
env_file: .env
|
||||
ports:
|
||||
- "5000:5000"
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0-android</TargetFramework>
|
||||
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>23.0.0</SupportedOSPlatformVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationId>com.CompanyName.PostIt</ApplicationId>
|
||||
<ApplicationVersion>1</ApplicationVersion>
|
||||
|
|
|
|||
|
|
@ -1,26 +1,28 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:PostIt.ViewModels"
|
||||
xmlns:views="using:PostIt.Views"
|
||||
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="PostIt.Views.MainView"
|
||||
x:DataType="vm:MainViewModel">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:PostIt.ViewModels"
|
||||
xmlns:views="using:PostIt.Views"
|
||||
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="PostIt.Views.MainView"
|
||||
x:DataType="vm:MainViewModel">
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainViewModel />
|
||||
</Design.DataContext>
|
||||
<StackPanel>
|
||||
|
||||
|
||||
<AvaloniaEdit:TextEditor
|
||||
ShowLineNumbers="True"
|
||||
FontFamily="Cascadia Code,Consolas,Menlo,Monospace"
|
||||
Background="AliceBlue"
|
||||
Foreground="Black"
|
||||
Watermark="Hit me strong!"
|
||||
/>
|
||||
<Label>Hello</Label>
|
||||
<AvaloniaEdit:TextEditor
|
||||
ShowLineNumbers="True"
|
||||
FontFamily="Cascadia Code,Consolas,Menlo,Monospace"
|
||||
Background="AliceBlue"
|
||||
Foreground="Black"
|
||||
Watermark="Hit me strong!"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ namespace Yavsc
|
|||
public const string FrontOfficeGroupName = "FrontOffice";
|
||||
public const string DefaultAvatar = "/images/Users/icon_user.png";
|
||||
public const string AnonAvatar = "/images/Users/icon_anon_user.png";
|
||||
public const string YavscConnectionStringEnvName = "YAVSC_CONNECTION_STRING";
|
||||
public const string YavscConnectionStringName = "YavscConnection";
|
||||
|
||||
// at the end, let 4*4 bytes in peace
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue