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

Commit ebc4e7b

Browse files
committed
Merge branch 'develop', prepare 2.0.2
2 parents 8875057 + e005a44 commit ebc4e7b

File tree

5 files changed

+55
-27
lines changed

5 files changed

+55
-27
lines changed

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,43 @@ Exoframe stores its config in `~/.exoframe/server.config.yml`.
5858
Currently it contains the following settings:
5959

6060
```yaml
61-
debug: false # whether debug mode is enabled, default "false"
62-
letsencrypt: false # whether to enable letsencrypt, default "false"
63-
letsencryptEmail: your@email.com # email used for letsencrypt
64-
compress: true # whether to apply gzip compression, default "true"
65-
baseDomain: false # base domain to use for deployments without domains specified, default "false"
66-
cors: false # CORS support; can be "true" ("*" header) or object with "origin" property, default "false"
67-
traefikImage: 'traefik:latest' # Traefik image to be used; set to "false" to disable traefik management, default "traefik:latest"
68-
traefikName: 'exoframe-traefik' # Traefik container name, default "exoframe-traefik"
69-
traefikArgs: [] # Additional Traefik start args, default []
70-
exoframeNetwork: 'exoframe' # Network used by traefik to connect services to, default "exoframe"
71-
updateChannel: 'stable' # server image update channel; can be "stable" or "nightly", default "stable"
72-
publicKeysPath: '/path/to/your/public/keys' # path to folder with authorized_keys, default "~/.ssh"
61+
# whether debug mode is enabled, default "false"
62+
debug: false
63+
64+
# whether to enable letsencrypt, default "false"
65+
letsencrypt: false
66+
67+
# email used for letsencrypt
68+
letsencryptEmail: your@email.com
69+
70+
# whether to apply gzip compression, default "true"
71+
compress: true
72+
73+
# base top-level domain to use for deployments without domains specified, default "false"
74+
# used as postfix, e.g. if you specify ".example.com" (dot is auto-prepended if not present)
75+
# all your deployments will be autodeployed as "deployment-id.example.com"
76+
baseDomain: false
77+
78+
# CORS support; can be "true" ("*" header) or object with "origin" property, default "false"
79+
cors: false
80+
81+
# Traefik image to be used; set to "false" to disable traefik management, default "traefik:latest"
82+
traefikImage: 'traefik:latest'
83+
84+
# Traefik container name, default "exoframe-traefik"
85+
traefikName: 'exoframe-traefik'
86+
87+
# Additional Traefik start args, default []
88+
traefikArgs: []
89+
90+
# Network used by traefik to connect services to, default "exoframe"
91+
exoframeNetwork: 'exoframe'
92+
93+
# server image update channel; can be "stable" or "nightly", default "stable"
94+
updateChannel: 'stable'
95+
96+
# path to folder with authorized_keys, default "~/.ssh"
97+
publicKeysPath: '/path/to/your/public/keys'
7398
```
7499
75100
_Warning:_ Most changes to config are applied immediately. With exception of Letsencrypt config. If you are enabling letsencrypt after Traefik instance has been started, you'll need to remove Traefik and then restart Exoframe server for changes to take effect.

src/docker/start.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// our modules
22
const docker = require('./docker');
33
const {initNetwork} = require('../docker/init');
4-
const {getProjectConfig, baseNameFromImage, nameFromImage, projectFromConfig, writeStatus} = require('../util');
4+
const {getProjectConfig, nameFromImage, projectFromConfig, writeStatus} = require('../util');
55
const {getConfig} = require('../config');
66

77
module.exports = async ({image, username, resultStream}) => {
8-
const baseName = baseNameFromImage(image);
98
const name = nameFromImage(image);
109

1110
// get server config
@@ -15,7 +14,11 @@ module.exports = async ({image, username, resultStream}) => {
1514
const config = getProjectConfig();
1615

1716
// generate host
18-
const defaultDomain = serverConfig.baseDomain ? `${name}${serverConfig.baseDomain}` : undefined;
17+
// construct base domain from config, prepend with "." if it's not there
18+
const baseDomain = serverConfig.baseDomain ? serverConfig.baseDomain.replace(/^(\.?)/, '.') : undefined;
19+
// construc default domain using given base domain
20+
const defaultDomain = baseDomain ? `${name}${baseDomain}` : undefined;
21+
// construct host
1922
const host = config.domain === undefined ? defaultDomain : config.domain;
2023

2124
// generate env vars
@@ -41,6 +44,9 @@ module.exports = async ({image, username, resultStream}) => {
4144
}
4245
const additionalLabels = config.labels || {};
4346

47+
// construct backend name from host (if available) or name
48+
const backend = host && host.length ? host : name;
49+
4450
// create config
4551
const containerConfig = {
4652
Image: image,
@@ -50,7 +56,7 @@ module.exports = async ({image, username, resultStream}) => {
5056
'exoframe.deployment': name,
5157
'exoframe.user': username,
5258
'exoframe.project': project,
53-
'traefik.backend': baseName,
59+
'traefik.backend': backend,
5460
}),
5561
HostConfig: {
5662
RestartPolicy,

src/util/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ exports.nameFromImage = image => {
4343
};
4444

4545
exports.projectFromConfig = ({username, config}) => {
46-
const tag = exports.tagFromConfig({username, config});
47-
const baseName = tag.split(':').shift();
46+
const image = exports.tagFromConfig({username, config});
47+
const baseName = exports.baseNameFromImage(image);
4848
return config.project || baseName;
4949
};
5050

test/deploy.test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,13 @@ test('Should deploy simple docker project', async done => {
7575
// check docker services
7676
const allContainers = await docker.listContainers();
7777
const containerInfo = allContainers.find(c => c.Names.includes(completeDeployments[0].Name));
78-
const deployId = completeDeployments[0].Name.split('-')
79-
.slice(-1)
80-
.shift();
8178
const name = completeDeployments[0].Name.slice(1);
8279

8380
expect(containerInfo).toBeDefined();
8481
expect(containerInfo.Labels['exoframe.deployment']).toEqual(name);
8582
expect(containerInfo.Labels['exoframe.user']).toEqual('admin');
8683
expect(containerInfo.Labels['exoframe.project']).toEqual('test-project');
87-
expect(containerInfo.Labels['traefik.backend']).toEqual(name.replace(`-${deployId}`, ''));
84+
expect(containerInfo.Labels['traefik.backend']).toEqual(`${name}.test`);
8885
expect(containerInfo.NetworkSettings.Networks.exoframe).toBeDefined();
8986

9087
const containerData = docker.getContainer(containerInfo.Id);
@@ -133,7 +130,7 @@ test('Should deploy simple node project', async done => {
133130
expect(container.Labels['exoframe.deployment']).toEqual(name);
134131
expect(container.Labels['exoframe.user']).toEqual('admin');
135132
expect(container.Labels['exoframe.project']).toEqual(name.replace(`-${deployId}`, ''));
136-
expect(container.Labels['traefik.backend']).toEqual(name.replace(`-${deployId}`, ''));
133+
expect(container.Labels['traefik.backend']).toEqual('localhost');
137134
expect(container.Labels['traefik.frontend.rule']).toEqual('Host:localhost');
138135
expect(container.NetworkSettings.Networks.exoframe).toBeDefined();
139136

@@ -177,7 +174,7 @@ test('Should deploy simple HTML project', async done => {
177174
expect(container.Labels['exoframe.deployment']).toEqual(name);
178175
expect(container.Labels['exoframe.user']).toEqual('admin');
179176
expect(container.Labels['exoframe.project']).toEqual('simple-html');
180-
expect(container.Labels['traefik.backend']).toEqual(name.replace(`-${deployId}`, ''));
177+
expect(container.Labels['traefik.backend']).toEqual(name);
181178
expect(container.Labels['traefik.frontend.rule']).toBeUndefined();
182179
expect(container.NetworkSettings.Networks.exoframe).toBeDefined();
183180

@@ -221,7 +218,7 @@ test('Should update simple HTML project', async done => {
221218
expect(container.Labels['exoframe.deployment']).toEqual(name);
222219
expect(container.Labels['exoframe.user']).toEqual('admin');
223220
expect(container.Labels['exoframe.project']).toEqual('simple-html');
224-
expect(container.Labels['traefik.backend']).toEqual(name.replace(`-${deployId}`, ''));
221+
expect(container.Labels['traefik.backend']).toEqual(name);
225222
expect(container.Labels['traefik.frontend.rule']).toBeUndefined();
226223
expect(container.NetworkSettings.Networks.exoframe).toBeDefined();
227224

@@ -498,7 +495,7 @@ test('Should deploy project with configured template', async done => {
498495
expect(container.Labels['exoframe.deployment']).toEqual(name);
499496
expect(container.Labels['exoframe.user']).toEqual('admin');
500497
expect(container.Labels['exoframe.project']).toEqual(name.replace(`-${deployId}`, ''));
501-
expect(container.Labels['traefik.backend']).toEqual(name.replace(`-${deployId}`, ''));
498+
expect(container.Labels['traefik.backend']).toEqual('localhost');
502499
expect(container.Labels['traefik.frontend.rule']).toEqual('Host:localhost');
503500
expect(container.NetworkSettings.Networks.exoframe).toBeDefined();
504501

test/fixtures/server.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
debug: true
22
letsencrypt: false
33
letsencryptEmail: test@gmail.com
4-
baseDomain: '.test'
4+
baseDomain: 'test'
55
cors:
66
origin: 'http://test.com'

0 commit comments

Comments
 (0)