Dockerized setup and development of upenu/website We moved everything here to the upenu/website repo directly, so you can look there for specifics on setting up the website dev stack with containers
- Install Docker and read up a little about how it works
- If you haven't started your docker daemon yet, run the command
sudo service docker start - Run the following command:
docker run --name upe-mysql -e MYSQL_ROOT_PASSWORD=littlewhale -d mysql/mysql-server:5.5- This creates and runs a docker based off of mysql's official ver 5.5 docker image, names it "upe-mysql", and sets the root password to "littlewhale". You can use the command
docker psto list running conainers and verify that it is running.
- This creates and runs a docker based off of mysql's official ver 5.5 docker image, names it "upe-mysql", and sets the root password to "littlewhale". You can use the command
- We'll need to shell into your mysql server you just created and run some SQL commands. Run the following command:
docker run -it --link upe-mysql:mysql --rm mysql/mysql-server:5.5 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"' - Now that you've entered the shell, we'll create the
upedatabase with the commandCREATE DATABASE upe; - We'll also create an admin user, and grant it privileges. Run
CREATE USER admin IDENTIFIED BY 'littlewhale';and thenGRANT ALL PRIVILEGES ON upe.* TO 'admin'; - Type
\qto quit the mysql server shell
- On your machine,
git clonethe upenu/website repo andcdinto it- Make sure to
cp upe/settings.py.template upe/settings.py, or nothing will work! - Also, if you are running OSX or Windows, make sure you
git clonein a subpath of your/UsersorC:\Usersdirectory respectively
- Make sure to
- Now we're going to create a container and execute some setup commands. Run
docker run -d -it --name upe-syncdb --link upe-mysql:mysql -v /path/to/website:/src/website upenu/website:dev python3 src/website/manage.py syncdb- On OSX, your path should be
/Users/<path_to_website> - On Windows, your path should be like
/c/Users/<path_to_website> - On Linux, you can use just the command
pwdto get the full path of the website folder when you are inside of it - What this command does:
docker runcreates a new docker container to run a command;-dmakes our container-itgives us a pseudo-TTY;--name upe-syncdbnames our container upe-syncdb;--link upe-mysql:mysqllinks our container with the mysql container we made earlier;-v /path/to/webite:/src/websitelets our docker container mount the volume on our host machine (lets us edit files easier); and the last part withpython3just runs a command :)
- On OSX, your path should be
- Django should ask you to create a superuser; do so and remember the username and password you use
- We're done using this container now, so we can remove it:
docker rm upe-syncdb - Now we'll create a new container for running the website. Run this command:
docker run -d -P --name upe-website --link upe-mysql:mysql -v /path/to/website:/src/website -w /src/website upenu/website:dev python3 /src/website/manage.py runserver 0.0.0.0:8000 - Docker will automatically map port 8000 in the container to a higher port on our real machine. Use the command
docker psto see all of the running containers on your system. For row corresponding to theupe-websitecontainer, you should see something like0.0.0.0:32768->8000/tcp. Go tolocalhost:32768or whatever port number is there in a web browser and bask in the glory of your own version of the upe website! - If you ever need to run Django commands etc. in your new docker container, you can use the
docker execcommand like so:docker exec upe-website python3 manage.py <command>- Note that we have changed our
cwd(current working directory) of the container to be/src/websitewhen we created our container
- Note that we have changed our