mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2026-02-04 19:04:12 +02:00
try to use environmnents
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -1,18 +1,17 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
ARG CLIENTID
|
|
||||||
ARG CLIENTSECRET
|
|
||||||
ARG REDIRECTURL
|
|
||||||
ARG PSQL_HOST
|
|
||||||
ARG PSQL_USER
|
|
||||||
ARG PSQL_PASSWORD
|
|
||||||
ARG PSQL_DATABASE
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||||
|
ENV CLIENTID 123
|
||||||
|
ENV CLIENTSECRET aAbB
|
||||||
|
ENV REDIRECTURL http://example.org/
|
||||||
|
ENV PSQL_HOST localhost
|
||||||
|
ENV PSQL_USER root
|
||||||
|
ENV PSQL_PASSWORD root
|
||||||
|
ENV PSQL_DATABASE database
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["yaflay.ru.csproj", "."]
|
COPY ["yaflay.ru.csproj", "."]
|
||||||
RUN dotnet restore "./yaflay.ru.csproj"
|
RUN dotnet restore "./yaflay.ru.csproj"
|
||||||
@@ -21,7 +20,7 @@ WORKDIR "/src/."
|
|||||||
RUN dotnet build "yaflay.ru.csproj" -c Release -o /app/build
|
RUN dotnet build "yaflay.ru.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
RUN dotnet publish "yaflay.ru.csproj" -c Release -o /app/publish /p:UseAppHost=false;redirectUrl=$REDIRECTURL;clientId=$CLIENTID;clientSecret=$CLIENTSECRET;Host=$PSQL_HOST;Username=$PSQL_USER;Password=$PSQL_PASSWORD;Database=$PSQL_DATABASE
|
RUN dotnet publish "yaflay.ru.csproj" -c Release -o /app/publish /p:UseAppHost=false;redirectUrl=$CLIENTID;clientId=;clientSecret=$CLIENTSECRET;Host=$PSQL_HOST;Username=$PSQL_USER;Password=$PSQL_PASSWORD;Database=$PSQL_DATABASE
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using yaflay.ru;
|
using yaflay.ru;
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main()
|
||||||
{
|
{
|
||||||
|
string args = Environment.CommandLine;
|
||||||
var parsedArgs = args.FirstOrDefault(k => k.StartsWith("/p:")).Replace("/p:", "").Split(";");
|
var parsedArgs = args.Split(";");
|
||||||
var parse = (string name) => parsedArgs.FirstOrDefault(k => k.StartsWith(name))?.Split("=")[1] ?? null;
|
var parse = (string name) => parsedArgs.FirstOrDefault(k => k.StartsWith(name))?.Split("=")[1] ?? null;
|
||||||
Startup.clientId = parse("clientId");
|
Startup.clientId = parse("clientId");
|
||||||
Startup.clientSecret = parse("clientSecret");
|
Startup.clientSecret = parse("clientSecret");
|
||||||
|
|||||||
Reference in New Issue
Block a user