From 311ba78b88fb15f16acf8980bb7a2b1b346333eb Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Wed, 15 Mar 2023 15:16:26 -0400 Subject: [PATCH] Fixed execute permission on service run file. Added healthcheck to Dockerfile and docker-compose file. Updated scripts for addtional functionality --- Dockerfile | 4 ++++ docker-build-dev.ps1 | 2 +- docker-compose.yml | 12 ++++++++--- docker-publish.ps1 | 21 ++++++++++++++++--- .../etc/s6-overlay/s6-rc.d/svc-rdt-client/run | 0 5 files changed, 32 insertions(+), 7 deletions(-) mode change 100644 => 100755 root/etc/s6-overlay/s6-rc.d/svc-rdt-client/run diff --git a/Dockerfile b/Dockerfile index 9d7ac81..4b5e039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,6 +85,7 @@ RUN \ ENV PATH "$PATH:/usr/share/dotnet" +# Copy files for app WORKDIR /app COPY --from=dotnet-build-env /appserver/server/out . COPY --from=node-build-env /appclient/client/out ./wwwroot @@ -93,3 +94,6 @@ COPY --from=node-build-env /appclient/root/ / # ports and volumes EXPOSE 6500 VOLUME ["/config", "/data" ] + +# Check Status +HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl --fail http://localhost:6500 || exit \ No newline at end of file diff --git a/docker-build-dev.ps1 b/docker-build-dev.ps1 index a184ece..e3808fd 100755 --- a/docker-build-dev.ps1 +++ b/docker-build-dev.ps1 @@ -17,7 +17,7 @@ Write-Host "removing Container (if exists)" docker rm rdtclientdev Write-Host "Building Container" -$dockerArgs = @( "build", "--force-rm", "--tag", "rdtclientdev", "--progress=$BuildProgress", "." ) +$dockerArgs = @( "build", "--force-rm", "--network host", "--tag", "rdtclientdev", "--progress=$BuildProgress", "." ) if ($IgnoreBuildCache.IsPresent) { $dockerArgs += @("--no-cace" ) } & docker $dockerArgs diff --git a/docker-compose.yml b/docker-compose.yml index 7987cf4..fe7af7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,9 @@ services: rdtclient: image: rogerfar/rdtclient container_name: rdtclient - build: - context: . - dockerfile: Dockerfile + # build: + # context: . + # dockerfile: Dockerfile environment: - PUID=1001 - PGID=1001 @@ -20,3 +20,9 @@ services: max-size: 10m ports: - '6500:6500' + healthcheck: + test: curl --fail http://localhost:6500 || exit 1 + interval: 30s + retries: 3 + start_period: 30s + timeout: 30s diff --git a/docker-publish.ps1 b/docker-publish.ps1 index c49e274..7132ccb 100755 --- a/docker-publish.ps1 +++ b/docker-publish.ps1 @@ -1,4 +1,4 @@ -#!/bin/pwsh +#!/usr/bin/env pwsh <# .SYNOPSIS Helper script to execute docker buildx @@ -34,12 +34,27 @@ param( [string]$Version = "", [string]$DockerAccount = "rogerfar", - [string]$Platforms = "linux/arm/v7,linux/arm64/v8,linux/amd64" + [string]$Platforms = "linux/arm/v7,linux/arm64/v8,linux/amd64", + [switch]$SkipPush, + [switch]$SkipCache, + [switch]$OutputToDocker ) $imageName = "$($DockerAccount)/rdtclient" -$dockerArgs = @( "buildx", "build", "--no-cache", "--push", "--platform", $Platforms, "--tag", "$($imageName):latest", "." ) +$dockerArgs = @( "buildx", "build", "--network=default", "--platform", $Platforms, "--tag", "$($imageName):latest", "." ) + +if (-Not $SkipPush.IsPresent) { + $dockerArgs += @("--push") +} + +if (-Not $SkipCache.IsPresent) { + $dockerArgs += @("--no-cache") +} + +if ($OutputToDocker.IsPresent) { + $dockerArgs += @("--output=type=docker") +} if ([string]::IsNullOrEmpty($Version)) { $Version = (Get-Content "package.json" | ConvertFrom-Json).version diff --git a/root/etc/s6-overlay/s6-rc.d/svc-rdt-client/run b/root/etc/s6-overlay/s6-rc.d/svc-rdt-client/run old mode 100644 new mode 100755