Skip to content

Commit

Permalink
Merge pull request #24 from redhat-scholars/containerfile
Browse files Browse the repository at this point in the history
rename dockerfile to containerfile
  • Loading branch information
kdubois authored May 22, 2024
2 parents c0c51d7 + 6f03cb9 commit ac1cab4
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 94 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
** xref:setup.adoc[Setup]
* I. Basics
** xref:dockerfile.adoc[Dockerfile]
** xref:containerfile.adoc[Containerfile]
** xref:imagemanagement.adoc[Image management]
** xref:runningcontainers.adoc[Running containers]
** xref:ports.adoc[Ports]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:project-name: tutorial-app

A https://docs.docker.com/engine/reference/builder/[Dockerfile] is where you'll estabilish the definitions used to build a container image. It uses three main keywords/commands:
A Containerfile, also known as a Dockerfile, is where you'll establish the definitions used to build a container image. It uses three main keywords/commands:

* FROM: where you'll inform the base image used to build your own image
* COPY: where you'll add resources (files) to your image
Expand Down Expand Up @@ -44,22 +44,28 @@ mvn package
----


== Building a Dockerfile
== Building a Containerfile

Create a file named Dockerfile.
Create a file named Containerfile.

[.console-input]
[source,bash,subs="+macros,+attributes"]
----
cat <<EOF >Dockerfile
FROM registry.access.redhat.com/ubi8/openjdk-17
cat <<EOF >Containerfile
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.18-4
COPY target/quarkus-app/lib/ /deployments/lib/
COPY target/quarkus-app/quarkus-run.jar /deployments/app.jar
COPY target/quarkus-app/app/ /deployments/app/
COPY target/quarkus-app/quarkus/ /deployments/quarkus/
ENV LANGUAGE='en_US:en'
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV JAVA_OPTS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
CMD ["java", "-jar", "/deployments/app.jar"]
EOF
----

26 changes: 16 additions & 10 deletions documentation/modules/ROOT/pages/env.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Environment variables

Environment variables keep your app secure, flexible and organized. Let's take a look at how to pass enviroment variables to containers.
Environment variables keep your app secure, flexible and organized. Let's take a look at how to pass environment variables to containers.

== Using an environment variable with your container

Expand Down Expand Up @@ -96,21 +96,27 @@ no config

The `no config` output happens because we didn't really create the environment variable. Let's fix it.

Edit your Dockerfile like this:
Edit your Containerfile like this (or simply add the `ENV config=dockerfile` line):

[.console-input]
[source,docker,subs="+macros,+attributes"]
----
FROM registry.access.redhat.com/ubi8/openjdk-17
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.18-4
COPY target/quarkus-app/lib/ /deployments/lib/
COPY target/quarkus-app/*.jar /deployments/app.jar
COPY target/quarkus-app/app/ /deployments/app/
COPY target/quarkus-app/quarkus/ /deployments/quarkus/
ENV LANGUAGE='en_US:en'
ENV config=dockerfile
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV JAVA_OPTS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENV config=containerfile
CMD ["java", "-jar", "/deployments/app.jar"]
----

Let's rebuild our image, re-create the container and call it again:
Expand All @@ -129,7 +135,7 @@ Now your output is:
[.console-output]
[source,text]
----
dockerfile
containerfile
----

Finally, let's replace the variable's content. First we remove the container:
Expand Down
87 changes: 37 additions & 50 deletions documentation/modules/ROOT/pages/imagemanagement.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

An image can be used to create and run containers. It is like a template, containing instructions on how to build the container. Images are the starting point for any container related activity, and can be thought of as a snapshot in a virtual machine (VM) environment.

== Building an image based on a Dockerfile
== Building an image based on a Containerfile (aka Dockerfile)

With the Dockerfile that we created in the last step, let's build a container image:
With the Containerfile that we created in the last step, let's build a container image:

[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand All @@ -17,25 +17,31 @@ You'll see an output like this:
[.console-output]
[source,text]
----
Sending build context to Docker daemon 10.95MB
Step 1/4 : FROM registry.access.redhat.com/ubi8/openjdk-11
latest: Pulling from ubi8/openjdk-11
396754cf27f9: Pull complete
41e1474940d5: Pull complete
fe52369f78c0: Pull complete
Digest: sha256:98c69a5b81bca0fe331100390c7357c69fd137e8a6228300eda820a0893a1be0
Status: Downloaded newer image for registry.access.redhat.com/ubi8/openjdk-11:latest
---> e502114b0d20
Step 2/4 : ADD target/lib/* /deployments/lib/
---> 47e879f30cec
Step 3/4 : ADD target/*-runner.jar /deployments/app.jar
---> 393bbade30ae
Step 4/4 : CMD ["java", "-jar", "/deployments/app.jar"]
---> Running in d09c7708954d
Removing intermediate container d09c7708954d
---> 87776d35fc85
Successfully built 87776d35fc85
Successfully tagged my-image:latest
STEP 1/11: FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.18-4
STEP 2/11: ENV LANGUAGE='en_US:en'
--> Using cache 7819ee5ffcddd7271987e306c787854c874bc81798370435d6efa7a89cc4990e
--> 7819ee5ffcdd
STEP 3/11: COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
--> 9b51381ccca6
STEP 4/11: COPY --chown=185 target/quarkus-app/*.jar /deployments/
--> 4d299e6fd3b4
STEP 5/11: COPY --chown=185 target/quarkus-app/app/ /deployments/app/
--> 6fce0c1e1dbc
STEP 6/11: COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
--> 7177bec47b2f
STEP 7/11: EXPOSE 8080
--> 9bd1b9ec7771
STEP 8/11: USER 185
--> 61bc6e589684
STEP 9/11: ENV JAVA_OPTS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
--> 08f8fe193e07
STEP 10/11: ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
--> 2f8f931e08b1
STEP 11/11: CMD ["java", "-jar", "/deployments/app.jar"]
COMMIT my-image
--> a8172ead99ee
Successfully tagged localhost/my-image:latest
a8172ead99eece385fa756e85948656896645f7f1848c68dfe498da9d93be073
----

== Listing the available images
Expand All @@ -54,11 +60,11 @@ You'll see at least these two outputs:
[source,text]
----
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image latest 87776d35fc85 4 minutes ago 516MB
registry.access.redhat.com/ubi8/openjdk-11 latest e502114b0d20 2 months ago 505MB
my-image latest 87776d35fc85 4 minutes ago 392MB
registry.access.redhat.com/ubi9/openjdk-21-runtime 1.18-4 80786be7434f 3 weeks ago 375 MB
----

Your image is the `my-image` and the `registry.access.redhat.com/ubi8/openjdk-11` is the image used to build yours.
Your image is the `my-image` and the `registry.access.redhat.com/ubi9/openjdk-21` is the image used to build yours.

== Removing images

Expand All @@ -70,36 +76,17 @@ To remove your just created image:
docker image rm my-image
----

// == Exploring the Desktop interfaces
== Exploring the Desktop interface

// Let's take a look at image management in the Desktop interfaces.
Let's take a look at image management in the Desktop interfaces.

// [tabs]
// ====
// Docker Desktop::
// +
// --
// Using Docker Desktop, we can see our newly created image in the *Images* tab. Here, we have information about the newly created image, including the the image ID, tag, creation date, and size of the image. Let's select the image name to see more information about the image.

// image::docker-desktop-images.png[alt="Docker Desktop Images tab", align="center"]
Podman Desktop::

// Here, we see information about the image hierarchy, as well as the various layers added, any vulnerabilities that may exist, and packages added.
With Podman Desktop, we can see our newly created image in the *Images* tab. We can find information about the newly created image, including the the image ID, tag, creation date, and size of the image. Let's select the image name to see more information about the image.

// image::docker-desktop-image-info.png[alt="Docker Desktop Image Info tab", align="center"]
image::podman-desktop-images.png[alt="Podman Desktop Images tab", align="center"]

// Returning back to the Images tab, we could also use the *Hub* tab to see our images that have been published to Docker Hub.
We can see information about the image layers, and low-level information about the image in JSON format.

// image::docker-desktop-hub.png[alt="Docker Desktop Hub tab", align="center"]
// --
// Podman Desktop::
// +
// --
// With Podman Desktop, we can see our newly created image in the *Images* tab. Here, we have information about the newly created image, including the the image ID, tag, creation date, and size of the image. Let's select the image name to see more information about the image.

// image::podman-desktop-images.png[alt="Podman Desktop Images tab", align="center"]

// Here, we see information about the image layers, and low-level information about the image in JSON format.

// image::podman-desktop-image-info.png[alt="Podman Desktop Image Info tab", align="center"]
// --
// ====
image::podman-desktop-image-info.png[alt="Podman Desktop Image Info tab", align="center"]
4 changes: 2 additions & 2 deletions documentation/modules/ROOT/pages/ports.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ Let's try to reach the application again:
curl localhost:8080/hello
----

You now got this output:
You should now see output like this:

[.console-output]
[source,text]
----
hello
Hello from Quarkus REST
----

This means that your application is now accessible!
10 changes: 5 additions & 5 deletions documentation/modules/ROOT/pages/pushing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ It's now ready to be pushed. Before doing it, you just need to login into your r

[tabs]
====
Docker Hub::
Quay.io::
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
docker login
docker login quay.io
----
--
Quay.io::
Docker Hub::
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
docker login quay.io
docker login
----
--
====

And finally you can push it:
And finally you can push it, eg.:

[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand Down
16 changes: 9 additions & 7 deletions documentation/modules/ROOT/pages/runningcontainers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ You now got an output like this:
[.console-output]
[source,text]
----
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-10-07 18:36:05,081 INFO [io.quarkus] (main) tutorial-app 1.0-SNAPSHOT on JVM (powered by Quarkus 1.8.2.Final) started in 0.651s. Listening on: http://0.0.0.0:8080
2020-10-07 18:36:05,105 INFO [io.quarkus] (main) Profile prod activated.
2020-10-07 18:36:05,105 INFO [io.quarkus] (main) Installed features: [cdi, resteasy]
INFO exec -a "java" java -Djava.util.logging.manager=org.jboss.logmanager.LogManager -cp "." -jar /deployments/quarkus-run.jar
INFO running in /deployments
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2024-05-22 10:53:37,988 INFO [io.quarkus] (main) tutorial-app 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.10.1) started in 0.455s. Listening on: http://0.0.0.0:8080
2024-05-22 10:53:37,989 INFO [io.quarkus] (main) Profile prod activated.
2024-05-22 10:53:37,989 INFO [io.quarkus] (main) Installed features: [cdi, rest, smallrye-context-propagation, vertx]
----

Notice that your terminal is attached to the container process. If you use `CTRL+C`, the container will stop.
Expand Down
14 changes: 5 additions & 9 deletions documentation/modules/ROOT/pages/setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ TIP: By default, the commands in this tutorial are using Docker, but you use `po
|===
|**Tool**|**macOS**|**Fedora**|**Windows**

| **Docker**
| https://docs.docker.com/desktop/install/mac-install/[Docker Desktop for Mac, window="_blank"]
| `dnf install docker`
| https://docs.docker.com/desktop/install/windows-install/[Docker Desktop for Windows, window="_blank"]

| **Podman**
| https://www.docker.com/products/docker-desktop[Podman Desktop for Mac, window="_blank"]
| `dnf install podman`
| https://podman-desktop.io/docs/Installation/windows-install[Podman Desktop for Windows, window="_blank"]

| **Podman Desktop**
| https://podman-desktop.io/downloads[Podman Desktop for Mac, window="_blank"]
| https://podman-desktop.io/downloads[Podman Desktop for Linux, window="_blank"]
| https://podman-desktop.io/downloads[Podman Desktop for Windows, window="_blank"]

| **Java 17**
| `brew tap AdoptOpenJDK/openjdk && brew cask install adoptopenjdk17`
Expand Down

0 comments on commit ac1cab4

Please sign in to comment.