Api docker buildx scripts

master
Tudor Stanciu 2022-06-18 18:05:14 +03:00
parent 463e43380e
commit 5415b78b8c
4 changed files with 32 additions and 5 deletions

View File

@ -46,7 +46,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{C5096F61-731
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
build-amd64.sh = build-amd64.sh build-amd64.sh = build-amd64.sh
release.sh = release.sh release.sh = release.sh
build-arm32.sh = build-arm32.sh buildx-arm32.sh = buildx-arm32.sh
buildx.sh = buildx.sh
EndProjectSection EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}"

22
buildx.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
echo "Welcome!"
version="1.0.5"
localRegistryPass="***REMOVED***"
#platform="linux/amd64,linux/arm64"
platform="linux/arm64"
echo "Login to alpine-nexus registry."
docker login --username=admin --password=$localRegistryPass alpine-nexus:8500
echo "Create docker image with version $version for platform $platform"
docker image build --build-arg APP_VERSION=$version -t "network-resurrector-api:$version" -f "src/api/NetworkResurrector.Api/Docker/Dockerfile" .
docker buildx build \
--build-arg APP_VERSION=$version \
--platform $platform \
--output=type=image,push=true,registry.insecure=true \
--push \
--tag alpine-nexus:8500/network-resurrector/network-resurrector-api:$version \
-f "src/api/NetworkResurrector.Api/Docker/amd64/Dockerfile" .
echo "Done!"

View File

@ -1,18 +1,17 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
ARG BASE_IMAGE_VERSION FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/aspnet:$BASE_IMAGE_VERSION AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src WORKDIR /src
COPY dependencies.props . COPY dependencies.props .
COPY Directory.Build.props . COPY Directory.Build.props .
COPY NuGet.config . COPY NuGet.config .
COPY ["src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj", "NetworkResurrector.Api/"] COPY ["src/api/NetworkResurrector.Api/NetworkResurrector.Api.csproj", "NetworkResurrector.Api/"]
COPY ["src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj", "NetworkResurrector.Api.Application/"] COPY ["src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj", "NetworkResurrector.Api.Application/"]
COPY ["src/api/NetworkResurrector.Api.PublishedLanguage/NetworkResurrector.Api.PublishedLanguage.csproj", "NetworkResurrector.Api.PublishedLanguage/"]
COPY ["src/api/NetworkResurrector.Api.Domain/NetworkResurrector.Api.Domain.csproj", "NetworkResurrector.Api.Domain/"] COPY ["src/api/NetworkResurrector.Api.Domain/NetworkResurrector.Api.Domain.csproj", "NetworkResurrector.Api.Domain/"]
COPY ["src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj", "NetworkResurrector.Api.Domain.Data/"] COPY ["src/api/NetworkResurrector.Api.Domain.Data/NetworkResurrector.Api.Domain.Data.csproj", "NetworkResurrector.Api.Domain.Data/"]
RUN dotnet restore "NetworkResurrector.Api/NetworkResurrector.Api.csproj" RUN dotnet restore "NetworkResurrector.Api/NetworkResurrector.Api.csproj"
@ -31,6 +30,11 @@ ENV urls="http://*:80"
ENV ConnectionStrings__DatabaseConnection="***REMOVED***" ENV ConnectionStrings__DatabaseConnection="***REMOVED***"
ENV IdentityServer__BaseAddress="http://***REMOVED***/" ENV IdentityServer__BaseAddress="http://***REMOVED***/"
ENV NetworkResurrectorServer__BaseAddress="http://***REMOVED***/" ENV NetworkResurrectorServer__BaseAddress="http://***REMOVED***/"
ENV TZ=Europe/Bucharest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ARG APP_VERSION=0.0.0.0
ENV APP_VERSION=${APP_VERSION}
#Workaround to lower the TLS level in container for old sql server version #Workaround to lower the TLS level in container for old sql server version
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf