Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chris/fix docker compose and url #247

Merged
merged 2 commits into from Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions docker-compose.yml
@@ -1,3 +1,5 @@
# docker-compose is provided for development purposes only and is not
Copy link
Contributor

@zacanger zacanger Jun 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an extremely good and important warning

# intended for use as a production entropic setup.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contact your doctor if symptoms persist for more than three days.

version: '3.1'
services:
db:
Expand Down Expand Up @@ -39,6 +41,12 @@ services:
- "3000:3000"
env_file:
- ./services/registry/.env
environment:
STORAGE_API_URL: http://storage:3002
PORT: 3000
WEB_HOST: http://localhost:3001
REDIS_URL: redis://redis:6379
EXTERNAL_HOST: http://localhost:3000

web:
image: mhart/alpine-node:12
Expand All @@ -52,6 +60,12 @@ services:
- "3001:3001"
env_file:
- ./services/web/.env
environment:
STORAGE_API_URL: http://storage:3002
PORT: 3001
WEB_HOST: http://localhost:3001
REDIS_URL: redis://redis:6379
EXTERNAL_HOST: http://localhost:3001

storage:
image: mhart/alpine-node:12
Expand All @@ -66,6 +80,13 @@ services:
# - "3002:3002"
env_file:
- ./services/storage/.env
environment:
POSTGRES_URL: postgres://postgres@db:5432
PGHOST: db
REDIS_URL: redis://redis:6379
PORT: 3002
PGUSER: postgres
PGDATABASE: entorpic_dev

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? entorpic instead of entropic 😛


volumes:
postgres_data:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -52,8 +52,8 @@
"lint-fix": "prettier --write '**/*.js'",
"lint-md": "markdownlint \"**/*.md\" -i \"**/node_modules/**\"",
"lint-registry": "cd services/registry; npm run lint",
"postinstall": "for d in cli services/{registry,workers,web,common/boltzmann}; do cd $d; npm i; cd -; done",
"postinstall": "for d in cli services/{registry,workers,web,storage,common/boltzmann}; do cd $d; npm i; cd -; done",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I don't think this will work on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would with git-bash or WSL. There's a lot in this project that I don't think would work with cmd.exe or powershell, I don't know of a good way around that besides maybe adding links to docs on WSL in HACKING.md.

"start": "docker-compose up",
"test": "for d in cli services/{registry,workers,web,common/boltzmann}; do cd $d; npm t; cd -; done"
"test": "for d in cli services/{registry,workers,web,storage,common/boltzmann}; do cd $d; npm t; cd -; done"
}
}
2 changes: 1 addition & 1 deletion services/common/boltzmann/request-handler.js
Expand Up @@ -29,7 +29,7 @@ class Context {
if (this._parsedUrl) {
return this._parsedUrl;
}
this._parsedUrl = new URL(this.request.url);
this._parsedUrl = new URL(this.request.url, 'http://entropic.dev');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, should be EXTERNAL_HOST, yes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to go with an (inert) URL here because the host value is never used except to keep new URL() from throwing an exception; whereas this code is used from a lot of different services which may not all need (or specify) EXTERNAL_HOST.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good LORD. Fine then.

return this._parsedUrl;
}
}
Expand Down
4 changes: 2 additions & 2 deletions services/registry/handlers/maintainers.js
Expand Up @@ -25,8 +25,8 @@ async function maintainers(context, { namespace, host, name }) {
host,
name,
bearer: context.user ? context.user.name : null,
page: Number(context.url.query.page) || 0,
status: context.url.query.status
page: Number(context.url.searchParams.get('page')) || 0,
status: context.url.searchParams.get('status')
})
.then(xs => [null, xs], xs => [xs, null]);

Expand Down
14 changes: 7 additions & 7 deletions services/registry/handlers/namespaces.js
Expand Up @@ -31,7 +31,7 @@ module.exports = [
async function namespaces(context, params) {
const [err, result] = await context.storageApi
.listNamespaces({
page: Number(context.url.query.page) || 0
page: Number(context.url.searchParams.get('page')) || 0
})
.then(xs => [null, xs], xs => [xs, null]);

Expand All @@ -47,9 +47,9 @@ async function namespaces(context, params) {
async function members(context, { namespace, host }) {
const [err, result] = await context.storageApi
.listNamespaceMembers({
page: Number(context.url.query.page) || 0,
page: Number(context.url.searchParams.get('page')) || 0,
bearer: context.user ? context.user.name : null,
status: context.url.query.status,
status: context.url.searchParams.get('status'),
namespace,
host
})
Expand Down Expand Up @@ -131,10 +131,10 @@ async function remove(context, { invitee, namespace, host }) {
async function memberships(context, { user }) {
const [err, result] = await context.storageApi
.listNamespaceMembers({
page: Number(context.url.query.page) || 0,
page: Number(context.url.searchParams.get('page')) || 0,
for: user,
bearer: context.user.name,
status: context.url.query.status
status: context.url.searchParams.get('status')
})
.then(xs => [null, xs], xs => [xs, null]);

Expand All @@ -150,8 +150,8 @@ async function memberships(context, { user }) {
async function maintainerships(context, { namespace, host }) {
const [err, result] = await context.storageApi
.listNamespaceMaintainerships({
page: Number(context.url.query.page) || 0,
status: context.url.query.status,
page: Number(context.url.searchParams.get('page')) || 0,
status: context.url.searchParams.get('status'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure there's a Good Reason™ why url.parse had to go away, leaving us with this less-nice API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will (grudgingly) cede that if you wanted to port this entire thing to a service worker based system of some cloudflare-y variety, you'd have to make this change anyway.

namespace,
host,
bearer: context.user.name
Expand Down
2 changes: 1 addition & 1 deletion services/registry/handlers/packages.js
Expand Up @@ -37,7 +37,7 @@ module.exports = [
async function packageList(context) {
const [err, result] = await context.storageApi
.listPackages({
page: Number(context.url.query.page) || 0
page: Number(context.url.searchParams.get('page')) || 0
})
.then(xs => [null, xs], xs => [xs, null]);

Expand Down
4 changes: 2 additions & 2 deletions services/registry/handlers/users.js
Expand Up @@ -20,8 +20,8 @@ async function memberships(context, { username }) {
.listUserMemberships({
for: username,
bearer: context.user.name,
page: context.url.query.page,
status: context.url.query.status
page: context.url.searchParams.get('page'),
status: context.url.searchParams.get('status')
})
.then(xs => [null, xs], xs => [xs, null]);

Expand Down
2 changes: 1 addition & 1 deletion services/storage/handlers/users.js
Expand Up @@ -32,7 +32,7 @@ async function tokens(context, { username }) {
}

const PER_PAGE = 100;
const offset = (Number(context.url.query.page) || 0) * PER_PAGE;
const offset = (Number(context.url.searchParams.get('page')) || 0) * PER_PAGE;

const tokens = await Token.objects
.filter({
Expand Down
2 changes: 1 addition & 1 deletion services/web/handlers/auth.js
Expand Up @@ -233,7 +233,7 @@ async function tokens(context) {
const { objects: tokens } = await context.storageApi.listTokens({
for: user,
bearer: user,
page: Number(context.url.query.page) || 0
page: Number(context.url.searchParams.get('page')) || 0
});
const cliLoginSession = context.session.get('cli');

Expand Down