Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit bee1f8c

Browse files
committed
Merge branch 'develop', prepare v6.0
2 parents 16c90da + 5934ce1 commit bee1f8c

29 files changed

+2827
-2151
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ language: node_js
55
services:
66
- docker
77

8-
node_js: 12
8+
node_js: lts/erbium
99

1010
cache: yarn
1111

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12.6-alpine
1+
FROM node:12.11-alpine
22

33
# install docker-compose
44
RUN apk update \

Dockerfile-debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:lts
1+
FROM node:12
22

33
# install required libs, docker-compose and yarn
44
RUN apt-get update && apt-get install python-pip -y && pip install docker-compose

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exoframe-server",
3-
"version": "5.0.4",
3+
"version": "5.0.5-dev",
44
"description": "Exoframe is a self-hosted tool that allows simple one-command deployments using Docker",
55
"main": "bin/server-core.js",
66
"bin": "bin/exoframe-server.js",
@@ -23,31 +23,31 @@
2323
"author": "Tim Ermilov <[email protected]>",
2424
"license": "MIT",
2525
"devDependencies": {
26-
"@zeit/ncc": "^0.20.4",
26+
"@zeit/ncc": "^0.20.5",
2727
"babel-eslint": "^10.0.3",
2828
"cors": "^2.8.4",
29-
"coveralls": "^3.0.6",
30-
"dockerode": "^2.5.6",
31-
"eslint": "^6.2.2",
32-
"eslint-config-prettier": "^6.1.0",
29+
"coveralls": "^3.0.7",
30+
"dockerode": "^3.0.2",
31+
"eslint": "^6.6.0",
32+
"eslint-config-prettier": "^6.5.0",
3333
"eslint-config-standard": "^14.1.0",
3434
"eslint-plugin-import": "^2.18.2",
35-
"eslint-plugin-node": "^9.1.0",
36-
"eslint-plugin-prettier": "^3.1.0",
35+
"eslint-plugin-node": "^10.0.0",
36+
"eslint-plugin-prettier": "^3.1.1",
3737
"eslint-plugin-promise": "^4.2.1",
3838
"eslint-plugin-standard": "^4.0.1",
3939
"exoframe-faas": "^1.0.1",
40-
"fastify": "^2.7.1",
41-
"fastify-auth": "^0.5.0",
40+
"fastify": "^2.10.0",
41+
"fastify-auth": "^0.6.0",
4242
"get-port": "^5.0.0",
4343
"highland": "^2.13.5",
4444
"jest": "^24.9.0",
4545
"js-yaml": "^3.12.0",
4646
"jsonwebtoken": "^8.3.0",
4747
"lodash": "^4.17.15",
48-
"lokijs": "^1.5.7",
48+
"lokijs": "^1.5.8",
4949
"mkdirp": "^0.5.1",
50-
"nock": "^10.0.4",
50+
"nock": "^11.7.0",
5151
"node-fetch": "^2.6.0",
5252
"prettier": "^1.18.2",
5353
"rimraf": "^3.0.0",

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const defaultConfig = {
8989
baseDomain: false,
9090
cors: false,
9191
updateChannel: 'stable',
92-
traefikImage: 'traefik:v1.7',
92+
traefikImage: 'traefik:latest',
9393
traefikName: 'exoframe-traefik',
9494
traefikArgs: [],
9595
exoframeNetwork: 'exoframe',

src/docker/init.js

Lines changed: 3 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,10 @@
1-
// npm modules
2-
const os = require('os');
3-
const fs = require('fs');
4-
const path = require('path');
5-
const mkdirp = require('mkdirp');
6-
71
// our modules
82
const {getConfig, waitForConfig} = require('../config');
93
const docker = require('./docker');
104
const logger = require('../logger');
115
const {initNetwork} = require('./network');
126
const {getPlugins} = require('../plugins');
13-
14-
// config vars
15-
const baseFolder = path.join(os.homedir(), '.exoframe');
16-
17-
// pull image
18-
const pullImage = tag =>
19-
new Promise(async (resolve, reject) => {
20-
let log = '';
21-
docker.pull(tag, (err, stream) => {
22-
if (err) {
23-
logger.error('Error pulling:', err);
24-
reject(err);
25-
return;
26-
}
27-
stream.on('data', d => {
28-
const line = d.toString();
29-
log += line;
30-
});
31-
stream.once('end', () => resolve(log));
32-
});
33-
});
34-
exports.pullImage = pullImage;
7+
const {initTraefik} = require('./traefik');
358

369
// export default function
3710
exports.initDocker = async () => {
@@ -44,20 +17,6 @@ exports.initDocker = async () => {
4417
// get config
4518
const config = getConfig();
4619

47-
// check if traefik management is disabled
48-
if (!config.traefikImage) {
49-
logger.info('Traefik managment disabled, skipping init..');
50-
return;
51-
}
52-
53-
// build acme path
54-
const acmePath = path.join(baseFolder, 'traefik', 'acme');
55-
try {
56-
fs.statSync(acmePath);
57-
} catch (e) {
58-
mkdirp.sync(acmePath);
59-
}
60-
6120
// run init via plugins if available
6221
const plugins = getPlugins();
6322
logger.debug('Got plugins, running init:', plugins);
@@ -75,102 +34,6 @@ exports.initDocker = async () => {
7534
}
7635
}
7736

78-
// get all containers
79-
const allContainers = await docker.listContainers({all: true});
80-
// try to find traefik instance
81-
const traefik = allContainers.find(c => c.Names.find(n => n.startsWith(`/${config.traefikName}`)));
82-
83-
// if traefik exists and running - just return
84-
if (traefik && !traefik.Status.includes('Exited')) {
85-
logger.info('Traefik already running, docker init done!');
86-
return;
87-
}
88-
89-
// if container is exited - remove and recreate
90-
if (traefik && traefik.Status.startsWith('Exited')) {
91-
logger.info('Exited traefik instance found, re-creating...');
92-
const traefikContainer = docker.getContainer(traefik.Id);
93-
// remove
94-
await traefikContainer.remove();
95-
}
96-
97-
// pull image if needed
98-
const allImages = await docker.listImages();
99-
const traefikImage = allImages.find(img => img.RepoTags && img.RepoTags.includes(config.traefikImage));
100-
if (!traefikImage) {
101-
logger.info('No traefik image found, pulling..');
102-
const pullLog = await pullImage(config.traefikImage);
103-
logger.debug(pullLog);
104-
}
105-
106-
// debug flags
107-
const debug = ['--debug', '--logLevel=DEBUG'];
108-
109-
// letsencrypt flags
110-
const letsencrypt = [
111-
'--acme',
112-
`--acme.email=${config.letsencryptEmail}`,
113-
'--acme.storage=/var/acme/acme.json',
114-
'--acme.httpchallenge.entrypoint=http',
115-
'--acme.entrypoint=https',
116-
'--acme.onhostrule=true',
117-
'--accesslogsfile=/var/acme/access.log',
118-
`--entryPoints=Name:https Address::443 TLS ${config.compress ? 'Compress:on' : 'Compress:off'}`,
119-
`--entryPoints=Name:http Address::80 Redirect.EntryPoint:https ${config.compress ? 'Compress:on' : 'Compress:off'}`,
120-
'--defaultEntryPoints=https,http',
121-
];
122-
123-
// entrypoints without letsencrypt
124-
const entrypoints = [
125-
`--entryPoints=Name:http Address::80 ${config.compress ? 'Compress:on' : 'Compress:off'}`,
126-
'--defaultEntryPoints=http',
127-
];
128-
129-
// construct command
130-
const Cmd = [
131-
'-c',
132-
'/dev/null',
133-
'--docker',
134-
'--docker.watch',
135-
...(config.letsencrypt ? letsencrypt : entrypoints),
136-
...(config.debug ? debug : []),
137-
...(config.traefikArgs || []),
138-
];
139-
140-
const Labels = {
141-
'exoframe.deployment': 'exo-traefik',
142-
'exoframe.user': 'admin',
143-
};
144-
145-
const RestartPolicy = {
146-
Name: 'on-failure',
147-
MaximumRetryCount: 2,
148-
};
149-
150-
// start traefik in docker
151-
const container = await docker.createContainer({
152-
Image: config.traefikImage,
153-
name: config.traefikName,
154-
Cmd,
155-
Labels,
156-
ExposedPorts: {
157-
'80/tcp': {},
158-
'443/tcp': {},
159-
},
160-
HostConfig: {
161-
RestartPolicy,
162-
Binds: ['/var/run/docker.sock:/var/run/docker.sock', `${acmePath}:/var/acme`],
163-
PortBindings: {
164-
'80/tcp': [{HostPort: '80'}],
165-
'443/tcp': [{HostPort: '443'}],
166-
},
167-
},
168-
});
169-
// connect traefik to exoframe net
170-
await exoNet.connect({
171-
Container: container.id,
172-
});
173-
// start container
174-
await container.start();
175-
logger.info('Traefik instance started..');
37+
// run traefik init
38+
await initTraefik(exoNet);
17639
};

0 commit comments

Comments
 (0)