Skip to content

Commit

Permalink
create docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Apr 18, 2018
1 parent 5996b68 commit 46e1a95
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 326 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
node_modules
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:8-alpine
MAINTAINER reruin

ADD . /app/
WORKDIR /app
VOLUME /app/config

RUN npm install

ENV HOST 0.0.0.0
ENV PORT 33001

EXPOSE 33001

CMD ["npm", "start"]
5 changes: 2 additions & 3 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
*/

var app = require('../app')
var config = require('../config.json')
var http = require('http');
var os = require('os')

var config = require('../config')
/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || config.port || '3001');
var port = normalizePort(config.port || 33001);
// app.set('port', port);

/**
Expand Down
14 changes: 4 additions & 10 deletions utils/config.js → config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const fs = require('fs')
const os = require('os')
const cache = require('./cache')
const config_path = process.cwd() +'/config.json'

var data = require('../config.json')

var app , handler


const config_path = process.cwd() +'/config/config.json'
const port = process.env.PORT || 33001

var data = {port}

async function save(d){
if(d.token) data.token = d.token
Expand All @@ -32,7 +27,6 @@ function installed(){
return data.token && data.path
}


module.exports = {
data, save , installed
data, save , installed , port
}
1 change: 0 additions & 1 deletion config.json

This file was deleted.

2 changes: 0 additions & 2 deletions controllers/gdlist.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const service = require('./../models/gdlist')
const base = require('../utils/base')
const request = require('request')
const config = require('../config')

const cache = {}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion controllers/install.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const base = require('../utils/base')
const request = require('request')
const config = require('../utils/config')
const config = require('../config')
const cache = require('../utils/cache')

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion controllers/manage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const service = require('./../models/gdlist')
const base = require('../utils/base')
const request = require('request')
const config = require('../utils/config')
const config = require('../config')
const cache = require('../utils/cache')

module.exports = {
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"
services:
gdlist:
image: reruin/gdlist
volumes:
- $HOME/gdlist:/app/config
ports:
- "33001:33001"
2 changes: 1 addition & 1 deletion middleware/koa-gdlist-install.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = require('../utils/config')
const config = require('../config')

module.exports = async (ctx , next)=>{
if(config.data.path && config.data.path.length){
Expand Down
2 changes: 1 addition & 1 deletion models/gdlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const http = require('../utils/http')
const base = require('../utils/base')
const cache = require('../utils/cache')
const config = require('../utils/config')
const config = require('../config')
const host = 'https://drive.google.com'
const format = require('../utils/format')

Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"name": "gdlist",
"version": "0.1.0",
"private": true,
"bin": "bin/www",
"repository": "https://github.com/reruin/gdlist",
"license": "Apache License 2.0",
"scripts": {
"start": "set NODE_ENV=dev && node bin/www",
"dev": "./node_modules/.bin/nodemon app",
"prd": "pm2 start app --env prod",
"build": "pkg . -t node9-win-x64 --output build/nrop_windows_amd64.exe && pkg . -t node9-macos-x64 --output build/nrop_macos_amd64 && pkg . -t node9-linux-x64 --output build/nrop_linux_amd64",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@koa/cors": "^2.2.1",
"iconv-lite": "^0.4.21",
"koa": "^2.2.0",
"koa-bodyparser": "^3.2.0",
"koa-json": "^2.0.2",
Expand All @@ -26,13 +25,6 @@
"pug": "^2.0.0-rc.1"
},
"devDependencies": {
"pkg": "^4.3.0",
"pm2": "^2.10.1"
},
"pkg": {
"assets": [
"./views/*",
"./public/**/*"
]
}
}
7 changes: 0 additions & 7 deletions utils/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const iconv = require('iconv-lite')

function rnd(min , max){
return Math.floor(min+Math.random()*(max-min));

Expand Down Expand Up @@ -34,10 +32,5 @@ module.exports = {

base64_decode(v){
return new Buffer(v.replace(/_/g,'/'), 'base64').toString()
},

gb2utf8(v){
// console.log(v)
return iconv.encode(v , 'gb2312').toString()
}
}
Loading

0 comments on commit 46e1a95

Please sign in to comment.