Skip to content

Commit c6b0a28

Browse files
committed
Adds Dockerfile and info on how to build and test the image
1 parent ddfc2ed commit c6b0a28

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

webapp/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM docker.io/bitnami/node:22
2+
3+
# Copy the app
4+
COPY app/ /app
5+
6+
WORKDIR /app
7+
# Install depencencies (express)
8+
RUN npm install
9+
10+
# Port to be exposed in the container
11+
EXPOSE 3000
12+
13+
# Run the app
14+
CMD node app.js

webapp/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,30 @@ $ curl http://localhost:3000/
7070
</html>
7171
```
7272

73+
## Building the container image
74+
75+
```bash
76+
$ docker build -t webapp:v0 .
77+
```
78+
79+
### Testing the container image
80+
81+
```bash
82+
$ docker run --name mywebapp --rm -p 3000:3000 -e WEBAPP_STRING='Hello world !!' webapp:v0
83+
Server running on port 3000
84+
```
85+
86+
```bash
87+
$ curl http://localhost:3000/
88+
89+
<html>
90+
<head>
91+
<title>Environment Variable and Server Hostname</title>
92+
</head>
93+
<body>
94+
<p>WEBAPP_STRING Environment Variable: Hello world !!</p>
95+
<p>Server Hostname: aa44cd3a60de</p>
96+
</body>
97+
</html>
98+
99+
```

0 commit comments

Comments
 (0)