Skip to content

Commit 09aacd8

Browse files
committed
v1.0.0
1 parent 42fab3f commit 09aacd8

File tree

9 files changed

+3267
-1
lines changed

9 files changed

+3267
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- "10"
4+
5+
install: npm install

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:12-alpine
2+
3+
RUN mkdir /restana-static
4+
WORKDIR /restana-static
5+
6+
COPY package.json .
7+
COPY package-lock.json .
8+
COPY index.js .
9+
COPY server.js .
10+
COPY config ./config
11+
COPY dist ./dist
12+
13+
RUN npm install --production
14+
15+
CMD ["node", "index.js"]
16+

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# restana-static
2-
Efficiently serve static files using Node.js and Docker containers.
2+
Efficiently serve static files using Node.js and Docker containers: https://itnext.io/restana-static-serving-the-frontend-with-node-js-beyond-nginx-e45fdb2e49cb
3+
4+
## Configuration options
5+
restana-static image configuration is manage using the module: https://www.npmjs.com/package/config, so developers can manage multiple envirments if desired.
6+
7+
The `/restana-static/config` directory should be populated/overwritten during image creation.
8+
9+
### Default configuration:
10+
```json
11+
{
12+
"port": 3000,
13+
"cacheEnabled": true,
14+
"cacheControlHeaderValue": "public, no-cache, max-age=604800",
15+
"distDirectory": "dist/",
16+
"defaultFile": "index.html",
17+
"logsFormat": "tiny"
18+
}
19+
```
20+
> File location : `/restana-static/config/default.json`
21+
22+
## Adding static files
23+
The `/restana-static/dist` directory should be populated/overwritten during image creation.
24+
> Please consider that default path will change if you overwrite the `distDirectory` config.
25+
26+
## Log formats
27+
Logs are provided by the module: https://www.npmjs.com/package/morgan
28+
29+
Allowed `logsFormat` values are described at: https://www.npmjs.com/package/morgan#predefined-formats
30+
31+
## Cache support
32+
Caching is provided by the module: https://www.npmjs.com/package/http-cache-middleware

config/default.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"port": 3000,
3+
"cacheEnabled": true,
4+
"cacheControlHeaderValue": "public, no-cache, max-age=604800",
5+
"distDirectory": "dist/",
6+
"defaultFile": "index.html",
7+
"logsFormat": "tiny"
8+
}

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { server, port } = require('./server')()
2+
3+
server.start(port)

0 commit comments

Comments
 (0)