serving/samples/helloworld-clojure: simplify and standardize Dockerfile (#499)

This commit is contained in:
Adam Ross 2018-11-20 12:23:20 -08:00 committed by Knative Prow Robot
parent a25fc162cb
commit 1176fc35c1
2 changed files with 22 additions and 20 deletions

View File

@ -1,20 +1,21 @@
# Start from a Debian image with the latest version of Clojure installed.
# Use the official Clojure image.
# https://hub.docker.com/_/clojure
FROM clojure
# Create the project and download dependencies.
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app/
COPY project.clj .
RUN lein deps
# Copy the local package files inside the container.
COPY . /usr/src/app
# Copy local code to the container image.
COPY . .
# Build the app as an uberjar.
# Build an uberjar release artifact.
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
# Run the app by default when the container starts.
CMD ["java", "-jar", "app-standalone.jar"]
# Configure and document the service HTTP port.
ENV PORT 8080
EXPOSE $PORT
# Document that the service listens on port 8080.
EXPOSE 8080
# Run the web service on container startup.
CMD ["java", "-jar", "app-standalone.jar"]

View File

@ -58,26 +58,27 @@ following instructions recreate the source files from this folder.
[the clojure image documentation](https://github.com/docker-library/docs/tree/master/clojure).
```docker
# Start from a Debian image with the latest version of Clojure installed.
# Use the official Clojure image.
# https://hub.docker.com/_/clojure
FROM clojure
# Create the project and download dependencies.
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app/
COPY project.clj .
RUN lein deps
# Copy the local package files inside the container.
COPY . /usr/src/app
# Copy local code to the container image.
COPY . .
# Build the app as an uberjar.
# Build an uberjar release artifact.
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
# Run the app by default when the container starts.
CMD ["java", "-jar", "app-standalone.jar"]
# Configure and document the service HTTP port.
ENV PORT 8080
EXPOSE $PORT
# Document that the service listens on port 8080.
EXPOSE 8080
# Run the web service on container startup.
CMD ["java", "-jar", "app-standalone.jar"]
```
1. Create a new file, `service.yaml` and copy the following service definition