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

Fix Janitor configuration; #207

Merged
merged 1 commit into from
Jan 25, 2018
Merged

Fix Janitor configuration; #207

merged 1 commit into from
Jan 25, 2018

Conversation

bnjbvr
Copy link
Collaborator

@bnjbvr bnjbvr commented Jan 16, 2018

Hey @jankeromnes, can you help me please? It's almost working, but I couldn't find out how to start the postgresql daemon from supervisord. Any idea here?

edit: starting from supervisord as I did doesn't work, for some reason (?).

@jankeromnes
Copy link
Contributor

Wow, super cool! Thanks for working on this fix. 😄

I also don't see anything wrong with your approach. Have you looked at sudo docker logs <your-test-container>? This will display the supervisor logs with any errors postresql might throw.

@bnjbvr
Copy link
Collaborator Author

bnjbvr commented Jan 16, 2018

Actually, scratch my issue: by cargo culting https://github.com/allisson/docker-postgresql/blob/master/supervisord.conf I've found a way that works.

@bnjbvr bnjbvr force-pushed the janitor branch 3 times, most recently from feea98e to 7432554 Compare January 16, 2018 23:49
@bnjbvr bnjbvr changed the title WIP: Fix Janitor configuration; Fix Janitor configuration; Jan 16, 2018
@bnjbvr
Copy link
Collaborator Author

bnjbvr commented Jan 16, 2018

This is ready for review:

  • @jankeromnes can you have a look at the Janitor changes, please?
  • @Chocobozzz too if you want; there's also a change to the watch:client command so that the front web server is exposed to all interfaces (viz. to the docker sub network). I think it's pretty safe.

Thanks!

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Thanks a lot for making this work! I have a few comments, but generally I'm fine with these changes if Chocobozzz is too 😄

# Configure Janitor for PeerTube.
ADD janitor.json /home/user/
RUN sudo chown user:user /home/user/janitor.json

# Configure and build PeerTube.
RUN yarn install \
&& npm run build
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Why do you no longer pre-build PeerTube?

Copy link
Owner

Choose a reason for hiding this comment

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

npm run dev will build the client on the fly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What @Chocobozzz said. Closing.

ADD create_user.sql /tmp/
RUN sudo service postgresql start && \
sudo -u postgres psql --file=/tmp/create_user.sql && \
sudo rm /tmp/create_user.sql
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Even if you delete files here, they'll remain part of the image history, since they were ADDed above. I suggest leaving this file somewhere useful, or running these steps with inline psql commands as opposed to a file.

Also, if this is really necessary to get PeerTube to work, why isn't it in a Makefile or in the package.json NPM scripts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Re: files: well, these are tiny, so I don't seem to care too much ;) I'll just let them in /tmp in this case.

Re: Makefile/package.json docs: it depends a lot on your database install / version; it's more of an external dependency that something mandated by PeerTube, so IMO it makes sense to keep it separate.

"label": "PeerTube API",
"proxy": "https"
},
"3000": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Super-nit: Please sort ports from smallest to largest (i.e. "3000" before "9000").

"proxy": "https"
},
"3000": {
"label": "PeerTube front",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: What about "web app" instead of "front"? I'd find that more explicit/transparent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I wanted to be picky, I'd say the API also uses web technologies and is an app, so it's also a web app ;) But yeah, it probably makes more sense overall :)

"proxy": "https",
"preview": true
}
},
"scripts": {
"Start PeerTube": "npm start",
"Start PeerTube": "npm run dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, why did you need to switch this? What's the difference between npm start and npm run dev?

Copy link
Owner

@Chocobozzz Chocobozzz Jan 17, 2018

Choose a reason for hiding this comment

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

npm start just serves the built server and the compiled client files. It's for production, after anpm run build.

npm run dev builds the server, run it on port 9000, builds the client on the fly and serves it on port 3000

@@ -0,0 +1,3 @@
[program:postgresql]
user = user
command = sudo -u postgres /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This command is very long. Why not make it shorter by using user = postgres like in the supervisor config example you found?

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 tried it the way you suggest, it didn't work, I don't have much time digging up why it didn't work, so meh 🤷‍. Happy to review a follow-up change to this if you're in the mood of making your PR thereafter.

sudo rm /tmp/supervisord-extra.conf

EXPOSE 3000
EXPOSE 9000
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You can expose multiple ports in one instruction like so.

@@ -2,4 +2,4 @@

cd client || exit -1

npm run ng -- server --hmr --host localhost --port 3000
npm run ng -- server --hmr --host 0.0.0.0 --port 3000
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks a bit scary, because you're exposing something to the world that was limited to localhost before. Could you please explain why this is needed? Is this a development server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not scary, it's only in development mode: note that this just means exposing the dev web server on the Docker network interface, which is needed if we want to expose the service outside of the container. Keeping it this way (the risk seems nonexistent to me).

@@ -15,10 +15,22 @@ WORKDIR /home/user/PeerTube
# Configure Cloud9 IDE to use PeerTube's source directory as workspace (-w).
RUN sudo sed -i "s/-w \/home\/user/-w \/home\/user\/PeerTube/" /etc/supervisord.conf

# Install dependencies.
RUN yarn install
Copy link
Owner

Choose a reason for hiding this comment

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

RUN yarn install --pure-lockfile

@bnjbvr
Copy link
Collaborator Author

bnjbvr commented Jan 25, 2018

Thanks for the reviews, @Chocobozzz @jankeromnes ! Mind to have another look, please? (this works on my machine; since the basic configuration works, and we still have no guarantees that absolute links will work in Janitor anyways, I'd like to not invest too much time on this)

@Chocobozzz
Copy link
Owner

Seems good for me. Waiting @jankeromnes validation.

Even if it does not work yet, we can merge and fix it in another PR :)

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks a lot for the great work! 🎉 🥇 💯

I can't wait to try this out in Janitor! 😄

@Chocobozzz Chocobozzz merged commit a585af3 into Chocobozzz:develop Jan 25, 2018
jankeromnes added a commit to jankeromnes/PeerTube that referenced this pull request Jan 25, 2018
PeerTube pre-build was removed in Chocobozzz#207 but is still valuable.
Chocobozzz pushed a commit that referenced this pull request Jan 25, 2018
PeerTube pre-build was removed in #207 but is still valuable.
@bnjbvr bnjbvr deleted the janitor branch February 13, 2018 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants