diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..a76a5ec34 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +ARG DOCKER_HUB="docker.io" + +FROM $DOCKER_HUB/library/node:10.10-alpine as build + + +COPY . /workspace/ + +ARG NPM_REGISTRY=" https://registry.npmjs.org" + +RUN echo "registry = \"$NPM_REGISTRY\"" > /workspace/.npmrc && \ + cd /workspace/ && \ + npm install && \ + npm run build + +ARG NGINX_VERSION="1.17.6" +FROM $DOCKER_HUB/library/nginx:$NGINX_VERSION AS runtime + + +COPY --from=build /workspace/dist/ /usr/share/nginx/html/ + +RUN chmod a+rwx /var/cache/nginx /var/run /var/log/nginx && \ + sed -i.bak 's/listen\(.*\)80;/listen 8080;/' /etc/nginx/conf.d/default.conf && \ + sed -i.bak 's/^user/#user/' /etc/nginx/nginx.conf + + +EXPOSE 8080 + +USER nginx + +HEALTHCHECK CMD [ "service", "nginx", "status" ] + + diff --git a/README.md b/README.md index 7b742e20d..a40fbc422 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,18 @@ Run `ng generate component component-name` to generate a new component. You can Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. +You can also build the application in a dedicated docker image using the provided `Dockerfile` as follows: + +``` +docker build -t spring-petclinic-angular:latest . +``` + +Then you will be able to use it as follows: + +``` +docker run --rm -p 8080:8080 spring-petclinic-angular:latest +``` + ## Documentation The documentation of the Spring Petclinic Angular application is generated by the [compodoc](https://compodoc.app) tool.