To create a container from this base image, simply copy the output from your SPA directory into the current
working directory of this image (/app). If you want to host this app on any other path than the
host site, you will need to in your reverse proxy rewrite the <base href="/"> tag with the
actual base path of the application in your reverse proxy. On startup, the container will read the contents of
the environment variable $APPSETTINGS and if it exists and have content, will echo the content into
a file hosted at /appsettings.json.
The current router outlet is , and the current settings is:
Example dockerfile – adjust as needed. This dockerfile assumes that it is located in the same directory as
your package.json, and that you have defined a build task where the output from
npm run build will be placed in a folder named dist at the same level as the
dockerfile.
FROM node:lts AS build ARG VERSION=1.0.0 WORKDIR /source COPY package.json package-lock.json ./ RUN npm clean-install RUN npm version ${VERSION} COPY . . RUN npm run build FROM proget.acossky.no/docker-dev/utils/spa-host:latest COPY --from=build /source/dist .
To test the app, use
docker
build
.
-t foo
followed by
docker run
-it
--rm
--build-arg VERSION=99.0.0-test
-p 8080:80
-e APPSETTINGS='{ \"key\": \"value\" }'
foo
and check the results at http://localhost:8080/