Skip to content

Commit 6092ae1

Browse files
committed
add docker setup
1 parent f36b692 commit 6092ae1

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assets/scripts/bundle

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# install dependencies
2+
FROM node:fermium-alpine
3+
WORKDIR /app-src
4+
5+
RUN npm i -g pnpm
6+
7+
COPY assets ./assets
8+
9+
COPY package.json ./
10+
RUN pnpm install
11+
12+
COPY apis ./apis
13+
COPY lib ./lib
14+
COPY index.js ./index.js
15+
16+
RUN pnpm run build
17+
18+
USER node
19+
20+
ENV PORT=3000
21+
ENV API="bahn"
22+
23+
CMD ["npm", "start"]

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import createServer from './lib/index.js'
22
import * as bahn from './apis/bahn/index.js'
33
import * as bus from './apis/bus/index.js'
44

5-
const port = process.env.PORT || 3000
5+
const port = (+process.env.PORT) || 3000
66
const apiId = process.env.API || 'bahn'
77

88
const apis = { bahn, bus }
@@ -14,5 +14,5 @@ const server = createServer(api)
1414
// start HTTP server
1515
server.listen(port, error => {
1616
if (error) return console.error(error)
17-
console.log(`HTTP: Listening on ${port}.`)
17+
console.log(`HTTP: Listening on port ${port}.`)
1818
})

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
"author": "Julius Tens <[email protected]>",
2929
"scripts": {
3030
"build": "npm run build-bahn && npm run build-bus",
31-
"build-bahn": "browserify 'assets/scripts/bahn.js' > 'assets/scripts/bundle/bahn.js'",
32-
"build-bus": "browserify 'assets/scripts/bus.js' > 'assets/scripts/bundle/bus.js'",
31+
"build-bahn": "mkdir -p assets/scripts/bundle && browserify 'assets/scripts/bahn.js' > 'assets/scripts/bundle/bahn.js'",
32+
"build-bus": "mkdir -p assets/scripts/bundle && browserify 'assets/scripts/bus.js' > 'assets/scripts/bundle/bus.js'",
3333
"check-deps": "depcheck . --ignore-dirs=bundle",
3434
"fix": "npm run lint -- --fix",
3535
"lint": "eslint --ignore-pattern /node_modules/ --ignore-pattern /assets/scripts/bundle/ .",
36+
"start": "node index.js",
3637
"test": "npm run lint && npm run check-deps"
3738
},
3839
"dependencies": {

0 commit comments

Comments
 (0)