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

Put peqp in a separate volume called "static" #27

Merged
merged 9 commits into from
Nov 14, 2017

Conversation

icyflame
Copy link
Member

I hope this is what you meant in your comment in #6 . The changes were pretty easy to make once I got the hang of it. 😄

  • This patch makes the mediawiki volume completely ephemeral

  • All static assets can be served from this subdomain: static.metakgp.org

  • Serving static assets from the same domain as the wiki turns out to be tricky, so I avoided it. It's just a DNS record and we can easily keep track of it.

  • The script at the end of this patch does the same thing as the restore mysql DB does. It is convenient to use:

    • On a pc in the KGP network: wget -r 10.17.32.9
    • Compress: tar czf peqp.tar.gz 10.17.32.9/
    • Rsync to server: rsync -avzhe "ssh" peqp.tar.gz root@IP:~
    • Extract at server: tar zxf peqp.tar.gz
    • Move to metakgp-wiki and then call the script: ./script/restore-peqp-to-static.sh 10.17.32.9 (The first argument is the directory that consists the peqp folder alongwith all the PDFs)

    I will add this to the runbook as soon as these two patches are merged in after testing it one more time.

@icyflame icyflame requested a review from amrav October 27, 2017 20:27
Copy link
Member

@amrav amrav 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, almost ready to merge - thanks!

nginx/Dockerfile Outdated
@@ -1,4 +1,5 @@
FROM nginx:mainline
COPY metakgp.org /etc/nginx/sites-enabled/
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename these to wiki.metakgp.org and static.metakgp.org?

@@ -27,7 +27,7 @@ server {
autoindex off;

# Make site accessible from everywhere
server_name _;
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately I think this causes things like locahost to stop working, which we want for development. Can you verify whether this is the case, and see if there's a way around it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey, I don't have docker installed on my computer. I did wget localhost on the server and that just gave me a 301 to the server URL. I will see if I have the space on my computer to set the whole thing up and check this.

location /peqp {
try_files $uri $uri/ =404;
}

location ~ ^/google557cb96b33ddc6b5\.html$ {}

location /images {
Copy link
Member

Choose a reason for hiding this comment

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

For the mediawiki volume to be truly ephemeral, we also want to put image uploads into the static volume. You could take a look at whether it's possible to configure media uploads to a separate subdomain, but I think the simplest solution might be to symlink the images dir to a dir in the static volume. Feel free to defer this to a later patch though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I got it. Will defer to a later patch.

nginx/static Outdated

root /srv/static;
# index index.php index.html;
# autoindex off;
Copy link
Member

Choose a reason for hiding this comment

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

Does this turn off showing an index of all the files? I think we want that to be off, but what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think we should turn it off too. The default is off. I will keep this in the config to keep it explicit.

nginx/static Outdated
@@ -0,0 +1,60 @@
# You may add here your
Copy link
Member

Choose a reason for hiding this comment

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

We can get rid of this boilerplate, I think.

@@ -7,6 +7,7 @@ services:
nginx:
volumes:
- mediawiki-volume:/srv/mediawiki
- static-volume:/srv/static
Copy link
Member

Choose a reason for hiding this comment

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

I think this belongs to the prod configuration - default and override should only contain config for development.


source .env
NGINX_CONTAINER=$(docker ps --format '{{ .Names }}' | grep nginx)
docker cp $1/. $NGINX_CONTAINER:/srv/static
Copy link
Member

Choose a reason for hiding this comment

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

I have a slight preference against having scripts to do very simple things, like run docker cp. Perhaps this belongs to the runbook instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, We could put this in the runbook, this script just felt natural beside the mysql backup restore script. I think we should keep it.

@icyflame
Copy link
Member Author

icyflame commented Nov 1, 2017

Rebased to latest master.

Remaining:

  • Check whether localhost works
  • Decide whether to have a separate script for restoring PEQP or put that in the runbook (I prefer having a script)

@icyflame
Copy link
Member Author

icyflame commented Nov 6, 2017

image

@amrav Localhost still works. I just setup a new server and tried it and it works. I have rebased to latest master and used this particular build to set this up. Please review and approve! 🙂

@icyflame
Copy link
Member Author

Hey @amrav, I have solved the issues now. Can you please review and merge? I think all the requirements have been met.

@amrav
Copy link
Member

amrav commented Nov 13, 2017

Lgtm if it works, but do you understand why nginx serves the correct domain for localhost? Why isn't it defaulting to static.metakgp.org, for instance?

@icyflame
Copy link
Member Author

@amrav Okay, the mechanism was easy to understand. It's well documented here

In particular:

image

A verbose log of the request:

image

So, the Host: localhost doesn't match anything configured and it just routes the request to the default_server which we have configured to be the wiki server.

I hope that clears it up. This was a good thing to find out! 😄 Okay to merge this patch now?

@amrav
Copy link
Member

amrav commented Nov 14, 2017 via email

@icyflame icyflame merged commit ae89734 into metakgp:master Nov 14, 2017
@icyflame icyflame deleted the icyflame/put-peqp-in-static branch November 25, 2017 06:40
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.

None yet

2 participants