Skip to content

Commit cd73795

Browse files
committed
Add Docker image
1 parent 286fa8b commit cd73795

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:16.17.1-alpine
2+
3+
LABEL maintainer="Johan Book"
4+
LABEL title="domain-file-server"
5+
LABEL description="File server with support for multiple domains"
6+
7+
WORKDIR /app
8+
COPY . .
9+
RUN npm ci
10+
11+
USER node
12+
13+
CMD ["node", "server.js"]
14+
15+
EXPOSE 8080

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# domain-file-server
1+
# file-domain-server
22

33
_This software has not been tested in regards of security and should not be used
44
in a production environment_
55

6-
**domain-file-server** is a simplistic Nodejs file server supporting multiple
7-
domains. It is mainly intended to run an internal network with its own DNS server.
6+
**file-server-domain** is a simplistic Nodejs file server supporting multiple
7+
domains. It is mainly intended to run an internal network with its own DNS
8+
server.
89

910
## Configuration
1011

@@ -27,3 +28,16 @@ build/mycat.com/favicon.ico
2728
build/mycat.com/index.html
2829
build/mycat.com/script.js
2930
```
31+
32+
## Docker
33+
34+
The server can be run through Docker
35+
36+
```sh
37+
docker run \
38+
--detach \
39+
--publish 8080:8080 \
40+
--restart unless-stopped \
41+
--volume ${PWD}/build/:/app/build/ \
42+
johanbook/file-domain-server:latest
43+
```

server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const http = require("http");
33
const path = require("path");
44

55
const DEFAULT_INDEX_FILE = process.env.DEFAULT_INDEX_FILE || "index.html";
6+
const PORT = process.env.PORT || 8080;
67
const ROOT_FILE_PATH = process.env.ROOT_FILE_PATH || "build";
78

89
function getFile(filePath) {
@@ -45,9 +46,10 @@ function handleRequest(req, res) {
4546
res.end();
4647
return;
4748
}
49+
4850
res.writeHead(200);
4951
res.end(file);
5052
}
5153

5254
const server = http.createServer(handleRequest);
53-
server.listen(8080);
55+
server.listen(PORT);

0 commit comments

Comments
 (0)