From 5415b78b8cdc9e63198651152a2107d0865232c5 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 18 Jun 2022 18:05:14 +0300 Subject: [PATCH] Api docker buildx scripts --- NetworkResurrector.sln | 3 ++- build-arm32.sh => buildx-arm32.sh | 0 buildx.sh | 22 +++++++++++++++++++ .../NetworkResurrector.Api/Docker/Dockerfile | 12 ++++++---- 4 files changed, 32 insertions(+), 5 deletions(-) rename build-arm32.sh => buildx-arm32.sh (100%) create mode 100644 buildx.sh diff --git a/NetworkResurrector.sln b/NetworkResurrector.sln index 125e0a4..b6991f4 100644 --- a/NetworkResurrector.sln +++ b/NetworkResurrector.sln @@ -46,7 +46,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{C5096F61-731 ProjectSection(SolutionItems) = preProject build-amd64.sh = build-amd64.sh release.sh = release.sh - build-arm32.sh = build-arm32.sh + buildx-arm32.sh = buildx-arm32.sh + buildx.sh = buildx.sh EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}" diff --git a/build-arm32.sh b/buildx-arm32.sh similarity index 100% rename from build-arm32.sh rename to buildx-arm32.sh diff --git a/buildx.sh b/buildx.sh new file mode 100644 index 0000000..6a3c93a --- /dev/null +++ b/buildx.sh @@ -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!" \ No newline at end of file diff --git a/src/api/NetworkResurrector.Api/Docker/Dockerfile b/src/api/NetworkResurrector.Api/Docker/Dockerfile index aa81efc..7cfc342 100644 --- a/src/api/NetworkResurrector.Api/Docker/Dockerfile +++ b/src/api/NetworkResurrector.Api/Docker/Dockerfile @@ -1,18 +1,17 @@ #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/core/aspnet:$BASE_IMAGE_VERSION AS base +FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base WORKDIR /app 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 COPY dependencies.props . COPY Directory.Build.props . COPY NuGet.config . 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.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.Data/NetworkResurrector.Api.Domain.Data.csproj", "NetworkResurrector.Api.Domain.Data/"] RUN dotnet restore "NetworkResurrector.Api/NetworkResurrector.Api.csproj" @@ -31,6 +30,11 @@ ENV urls="http://*:80" ENV ConnectionStrings__DatabaseConnection="***REMOVED***" ENV IdentityServer__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 RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf