From fda33b20d1e26a2a35cede26fa09d1b36845db52 Mon Sep 17 00:00:00 2001 From: Remco Ros Date: Sat, 27 Jul 2024 10:46:34 +0000 Subject: [PATCH] generate index.html in container at build time --- Dockerfile | 31 ++++++++++++++++++++++--------- Makefile | 5 +++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index baf2228..c08031a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,37 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine as build +# install nodejs/npm to build cc-implementation +RUN apk update && apk add --no-cache nodejs npm + WORKDIR /app -COPY ./src/PushTX . - +COPY ./src . + +# regenerate index.html from source RUN \ + cd /app/cc-implementation && \ + npm install && \ + npm run build + +# compile PushTX app +RUN \ + cd /app/PushTX && \ dotnet restore && \ dotnet publish -c Release -o out +# start from aspnet runtime FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine -RUN apk update && \ - apk add --no-cache \ - nginx yq \ +# install nginx and yq +RUN \ + apk update && \ + apk add --no-cache nginx yq && \ rm -rf \ - /tmp/* \ - /var/cache/apk/* \ - /var/tmp/* + /tmp/* \ + /var/cache/apk/* \ + /var/tmp/* WORKDIR /app COPY --chmod=755 ./docker_entrypoint.sh /app/docker_entrypoint.sh -COPY --from=build /app/out /app +COPY --from=build /app/PushTX/out /app diff --git a/Makefile b/Makefile index 76b95c8..bbde676 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PKG_ID := $(shell yq e ".id" manifest.yaml) PKG_VERSION := $(shell yq e ".version" manifest.yaml) TS_FILES := $(shell find ./scripts -name \*.ts) +SOURCES := $(shell find ./src ! -path "*/obj/*" ! -path "*/bin/*" ! -path "*/node_modules/*") # sha256 hashes can be found in https://github.com/mikefarah/yq/releases/download/v4.40.7/checksums-bsd YQ_VERSION := 4.40.7 @@ -40,7 +41,7 @@ clean: scripts/embassy.js: $(TS_FILES) deno bundle scripts/embassy.ts scripts/embassy.js -docker-images/aarch64.tar: manifest.yaml Dockerfile docker_entrypoint.sh +docker-images/aarch64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(SOURCES) ifeq ($(ARCH),x86_64) else mkdir -p docker-images @@ -51,7 +52,7 @@ else --platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar . endif -docker-images/x86_64.tar: manifest.yaml Dockerfile docker_entrypoint.sh +docker-images/x86_64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(SOURCES) ifeq ($(ARCH),aarch64) else mkdir -p docker-images