Categories
code tech

Raspberry Pi WordPress Blog with Docker

Ever wanted to quickly get a wordpress blog up and running on your Raspberry Pi? Well here’s how you can do it!

Prerequisite:

Raspberry Pi – https://amzn.to/36i6T5P*Amazon Affiliate Link*

This assumes you have a raspberry pi with Raspbian installed.

Install docker and docker compose

sudo apt-get install docker.io docker-compose

create a place for the blog to live

mkdir blog
cd blog

Create the following 3 files using your favourite text editor

docker-compose.yml

version: '3'
services:
    wordpress:
        container_name: wordpress
        image: wordpress
        volumes:
            - '/home/pi/blog/html:/var/www/html'
        ports:
            - '80:80'
        env_file:
            - blog_env
    mysql:
        container_name: mysql
        image: hypriot/rpi-mysql
        volumes:
            - '/home/pi/blog/data:/var/lib/mysql'
        env_file:
            - mysql_env
    redis:
        image: redis
        container_name: redis
volumes:
    mysql: null
    wordpress: null

mysql_env

MYSQL_ROOT_PASSWORD=secret
MYSQL_DATABASE=blog
MYSQL_USER=blog_user
MYSQL_PASSWORD=blogSecret

blog_env

WORDPRESS_DB_HOST=mysql
WORDPRESS_DB_USER=blog_user
WORDPRESS_DB_PASSWORD=blogSecret
WORDPRESS_DB_NAME=blog

Finally, run the following command to launch the blog:

sudo docker-compose up -d --build

Categories
code

Getting gunicorn + flask working in Docker on Windows 10

I was attempting to write a flask python app and have it containerized on Windows but going to localhost:5000 resulted in an empty response.

FROM python:3
...

WORKDIR /opt/famdo/src
CMD ["gunicorn", "-b",  "127.0.0.1:8000", "wsgi:app"]

EXPOSE 8000

The above Dockerfile works perfectly fine in Linux if you hit localhost:8000 from the host. From windows it doesn’t work. The solution is simple!

FROM python:3
...
WORKDIR /opt/famdo/src
CMD ["gunicorn", "-b",  "0.0.0.0:8000", "wsgi:app"]

EXPOSE 8000

Bind to 0.0.0.0 instead of 127.0.0.1 and voila! You can now hit that endpoint via localhost in windows.

Categories
code game development thoughts video

Indie Game Devs – How important is beautiful code?

If you’re an indie game developer, how important having “good code”? I dive into this topic discussing the pros and cons of having beautiful code.