Add pipline/prebuild.yml
This commit is contained in:
parent
7918744490
commit
583d1108fa
66
pipline/prebuild.yml
Normal file
66
pipline/prebuild.yml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
stages:
|
||||||
|
- prepare
|
||||||
|
- build
|
||||||
|
|
||||||
|
variables:
|
||||||
|
DOCKER_TAG: "my-app:latest"
|
||||||
|
CONFIG_ENV: "Development" # можно использовать для генерации appsettings.{ENV}.json
|
||||||
|
|
||||||
|
prepare:
|
||||||
|
stage: prepare
|
||||||
|
script:
|
||||||
|
# Генерация Dockerfile
|
||||||
|
- |
|
||||||
|
cat <<EOF > Dockerfile
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet restore
|
||||||
|
RUN dotnet publish -c Release -o /app/publish
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "MyApp.dll"]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Генерация nuget.config
|
||||||
|
- |
|
||||||
|
cat <<EOF > nuget.config
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Генерация appsettings.json
|
||||||
|
- |
|
||||||
|
cat <<EOF > appsettings.json
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Environment": "$CONFIG_ENV"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- Dockerfile
|
||||||
|
- nuget.config
|
||||||
|
- appsettings.json
|
||||||
|
expire_in: 1 hour
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- docker build -t $DOCKER_TAG .
|
||||||
Loading…
x
Reference in New Issue
Block a user