Skip to content

Commit

Permalink
Create a production dockerfile that copies all the files into the image
Browse files Browse the repository at this point in the history
Instead of mounting them from a local directory. This allows us to scan the
webapp for vulnerabilities before deploying it.

This is essentially a port of
e-mission/em-public-dashboard@a2e1134
which is why it is so quick :)

Testing done:

- Builds

```
Building joinpage
[+] Building 0.2s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                                     0.0s
 => => transferring dockerfile: 153B                                                                     0.0s
 => [internal] load .dockerignore                                                                        0.0s
 => => transferring context: 2B                                                                          0.0s
 => [internal] load metadata for docker.io/danjellz/http-server:1.4                                      0.0s
 => [1/4] FROM docker.io/danjellz/http-server:1.4                                                        0.0s
 => [internal] load build context                                                                        0.0s
 => => transferring context: 574.10kB                                                                    0.0s
 => CACHED [2/4] RUN mkdir -p /public                                                                    0.0s
 => [3/4] COPY ../client /public/client                                                                  0.0s
 => [4/4] COPY ../*.html /public                                                                         0.0s
 => exporting to image                                                                                   0.0s
 => => exporting layers                                                                                  0.0s
 => => writing image sha256:1771294c6bf63063a06cfec67f58da9d3dbf931979d4d91bf57c1ecb0108e060             0.0s
 => => naming to docker.io/library/study-join-page_joinpage                                              0.0s
```

- Runs

```
$ docker-compose -f docker-compose.yml up
Recreating study-join-page_joinpage_1 ... done
Attaching to study-join-page_joinpage_1
joinpage_1  | Available on:
joinpage_1  |   http://127.0.0.1:8080
joinpage_1  |   http://172.20.0.2:8080
joinpage_1  | Hit CTRL-C to stop the server
joinpage_1  |
joinpage_1  | [2022-09-09T15:42:15.334Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
joinpage_1  | (node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
joinpage_1  | (Use `node --trace-deprecation ...` to show where the warning was created)
joinpage_1  | [2022-09-09T15:42:15.415Z]  "GET /client/js/jquery.min.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
joinpage_1  | [2022-09-09T15:42:15.416Z]  "GET /client/js/bootstrap.bundle.min.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
joinpage_1  | [2022-09-09T15:42:15.417Z]  "GET /client/js/jquery.gridster.min.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
joinpage_1  | [2022-09-09T15:42:15.417Z]  "GET /client/js/plugins.min.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
joinpage_1  | [2022-09-09T15:42:15.418Z]  "GET /client/js/app.min.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0"
```

- Displays correctly in the browser
  • Loading branch information
shankari committed Sep 9, 2022
1 parent 96eeb3a commit 230cd37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3"
services:
joinpage:
build:
context: frontend
dockerfile: docker/Dockerfile
ports:
# DASH in numbers
- "3274:8080"
networks:
- emission

networks:
emission:
5 changes: 5 additions & 0 deletions frontend/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM danjellz/http-server:1.4

RUN mkdir -p /public
COPY ../client /public/client
COPY ../*.html /public

0 comments on commit 230cd37

Please sign in to comment.