Here’s the bash script. Just change your shell to bash, install vagrant plugin and edit
Vagrantfile settings. Then run the script.
If you’re here, then you probably know what Alpine is. So here’s a tutorial on how I setup my Django projects with it. (Projects are in Python 3.5). Also, I assume you have vagrant installed.
Installing the Plugin
I use Vagrant for VM’s since it’s convenient but before we can install our Alpine image we have to install a plugin that will make our lives easier. It basically “patches” some of the vagrant commands to work with Alpine. Just follow the installation instructions there.
Setting up the VM
After that we can go ahead and create our VM. Go to any directory that you want your project to be in and run:
This will create a file called
Vagrantfile. Let’s go ahead on edit this file and uncomment the lines that have the following:
The first line is pretty self-explanatory, we access port 8000 on our local machine and then it goes, fetches and displays whatever port 80 on our VM points to. The second line is needed by the line below it. The final line is pretty important too, it’s so we can share the folders/files between machines, this makes life a whole lot easier. Let’s edit that line so that it fits our needs. On my directory I have another directory called
project and I place everything there, so let’s re-write this to:
I just placed everything in the home directory of the VM, you can change it to wherever you’d like. You probably noticed the
type argument as well. We need to pass this so that we can sync folders/files without any problem, I couldn’t get it to work through the traditional way, so this is a work around.
Update the Package Manager
Now that everything is setup, let’s start our VM with.
You should start seeing text popup, just let it all go through. Eventually you should see some errors too. Don’t panic, that’s what supposed to happen because the VM needs to fix it’s repo url. After we fix that, the next time you boot you should be asked to enter your password, this is so that we can use NFS.
Once it’s all done throwing errors, run:
If it asks you for a password, it’s
vagrant. Now just update and upgrade.
By default, Alpine sets you up with
/bin/ash but I like
/bin/bash. Unfortunately there is no
chsh command so we’re going to have to edit
You should see something like this:
just change the last bit to:
Installing Python 3 and Pip
Alright, now for Python. This is where it gets easy. Just run:
You should be able to use Python 3.5 after running
python3 on the shell.
The other stuff is just dependencies that we’ll need later on.
Next, is pip. These commands should do the trick:
Ta-da! We have pip installed too. Life is wonderful huh?
I’ll be using Postgresql for the database in this tutorial. So here’s how to install it.
Next, let’s start the service.
If you want to start the DB on boot, do
rc-update add postgresql.
Let’s setup the the DB
We’ll use virtualenvwrapper for our needs
Next, let’s add this to our
The just run
source .bashrc. Note: If you’re not using
bash then sourcing the file will raise errors.
Finally, we can just install nginx using the package manager.
If you want a conf file for nginx and gunicorn working together then I recommend you read this post by another person. It’s easy to follow.