Skip to content

Commit

Permalink
Merge pull request spring-petclinic#41 from antechrestos/features/add…
Browse files Browse the repository at this point in the history
…-dockerfile

Add dockerfile to build application in a docker nginx image
  • Loading branch information
arey authored Sep 5, 2020
2 parents cd68c8b + d222fa9 commit 4f58177
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]


12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4f58177

Please sign in to comment.