Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
b86b542998 | |||
3caa4a51db | |||
0d311ac19c | |||
a90feaffdf | |||
ee45331b4d | |||
0c763cafd3 | |||
0ec819e232 | |||
c74f486b7e | |||
cc5d07595b |
4 changed files with 27 additions and 18 deletions
|
@ -3,7 +3,7 @@ version: 2.0
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:8.9.4
|
- image: circleci/node:8
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
|
@ -15,3 +15,7 @@ jobs:
|
||||||
- run:
|
- run:
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
command: npm test
|
command: npm test
|
||||||
|
- setup_remote_docker
|
||||||
|
- run:
|
||||||
|
name: Build docker container
|
||||||
|
command: docker build .
|
||||||
|
|
25
Dockerfile
25
Dockerfile
|
@ -1,18 +1,27 @@
|
||||||
FROM node:8.10.0-alpine
|
FROM node:8-alpine
|
||||||
|
|
||||||
RUN mkdir -p /public
|
COPY ./src /opt/tstatic/src
|
||||||
|
COPY ./package.json opt/tstatic/package.json
|
||||||
|
COPY ./package-lock.json opt/tstatic/package-lock.json
|
||||||
|
COPY ./tsconfig.json opt/tstatic/tsconfig.json
|
||||||
|
COPY ./site /var/www
|
||||||
|
|
||||||
COPY ./src /app/src
|
WORKDIR /opt/tstatic
|
||||||
COPY ./package.json /app/package.json
|
|
||||||
COPY ./package-lock.json /app/package-lock.json
|
|
||||||
COPY ./tsconfig.json /app/tsconfig.json
|
|
||||||
|
|
||||||
WORKDIR /app
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
|
ENV NODE_ENV production
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
CMD npm start -- /public
|
RUN npm prune --production
|
||||||
|
|
||||||
|
RUN npm install -g .
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
CMD tstatic /var/www
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
The only static-file server you'll ever need!
|
The only static-file server you'll ever need!
|
||||||
|
|
||||||
### Features:
|
### Features:
|
||||||
- Logging - [`winston`](https://www.npmjs.com/package/winston)
|
|
||||||
- Basic-Auth - [`basic-auth`](https://www.npmjs.com/package/basic-auth)
|
- Basic-Auth - [`basic-auth`](https://www.npmjs.com/package/basic-auth)
|
||||||
- Custom 404 page
|
- Custom 404 page
|
||||||
- Optimum Compression - [`compression`](https://www.npmjs.com/package/compression)
|
- Optimum Compression - [`compression`](https://www.npmjs.com/package/compression)
|
||||||
|
@ -25,7 +24,6 @@ The only static-file server you'll ever need!
|
||||||
-b <auth> --basic-auth=<auth> Enable basic-auth.
|
-b <auth> --basic-auth=<auth> Enable basic-auth.
|
||||||
-i <ips> --ips=<ips> Allowed IP addresses.
|
-i <ips> --ips=<ips> Allowed IP addresses.
|
||||||
-l --list-dir List Directory.
|
-l --list-dir List Directory.
|
||||||
--opbeat Enable Opbeat.
|
|
||||||
-o --open Open in browser after start.
|
-o --open Open in browser after start.
|
||||||
```
|
```
|
||||||
`dir` is where your static files are.
|
`dir` is where your static files are.
|
||||||
|
@ -55,7 +53,7 @@ Enables directory listing. Allow browseing
|
||||||
Open the server in the browser one started. It will open in your default browser, and use url `http://0.0.0.0:<port>`.
|
Open the server in the browser one started. It will open in your default browser, and use url `http://0.0.0.0:<port>`.
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
Included in this repo is a `Dockerfile` to use. The default setup requires being run from the project directory, and will serve `/public` in the container on port `5000`. By default, this directory is empty, however can be overriden.
|
Included in this repo is a `Dockerfile` to use. The default setup requires being run from the project directory, and will serve `/var/www` in the container on port `5000`. By default, this directory is contains a simple index file, however can be overriden.
|
||||||
|
|
||||||
Below is an example `docker-compose.yml` file you can use with it:
|
Below is an example `docker-compose.yml` file you can use with it:
|
||||||
|
|
||||||
|
@ -68,9 +66,7 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./site/:/public
|
- ./site/:/var/www
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
```
|
```
|
||||||
|
|
||||||
__Note__: `tstatic` isn't installed into the path, so run it using `npm start --`
|
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./dist/index.js",
|
"start": "node ./dist/index.js",
|
||||||
"prepublish": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "npm run lint && npm run mocha",
|
"test": "npm run lint && npm run mocha",
|
||||||
"mocha": "mocha --require scripts/test-helper.js --recursive --bail tests/**/*.test.ts tests/*.test.ts",
|
"mocha": "mocha --require scripts/test-helper.js --recursive --bail tests/**/*.test.ts tests/*.test.ts",
|
||||||
"lint": "tslint src/**/*.ts --project tsconfig.json"
|
"lint": "tslint src/**/*.ts --project tsconfig.json"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "8.10.0"
|
"node": "8"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Reference in a new issue