Skip to content

Commit

Permalink
generate index.html in container at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
remcoros committed Jul 27, 2024
1 parent ff9474a commit fda33b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
31 changes: 22 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fda33b2

Please sign in to comment.