DEV Community

Cover image for Running dev.to in a container Part 2
Chuck Ha
Chuck Ha

Posted on

Running dev.to in a container Part 2

In my last post I covered building a docker image, but it was so rushed I won't even link it here.

This article aims to improve on that mess of a Dockerfile.

The commit can be found on my fork of the dev.to repo.

In order to get this version of dev.to running locally follow these steps (no cloning necessary):

# Setup a data directory for postgres
mkdir data

# Create the network that is shared between containers
docker network create devto

# Run the database
docker run --rm --network devto --name db -e POSTGRES_PASSWORD=devto -e POSTGRES_USER=devto -e POSTGRES_DB=PracticalDeveloper_development -v $(PWD)/data:/var/lib/postgresql/data postgres:10

and then in another terminal follow these steps for the application server:

# Setup the database and ensure dependencies are met
docker run --rm -it --network devto -e CONNECT_TIMEOUT=30 -e DATABASE_URL=postgresql://devto:devto@db:5432/PracticalDeveloper_development chuckdha/dev.to:latest bin/setup

# Run the webserver
docker run --rm -it --network devto -p 3000:3000 -e CONNECT_TIMEOUT=30 -e DATABASE_URL=postgresql://devto:devto@db:5432/PracticalDeveloper_development chuckdha/dev.to:latest bin/rails s

Then visit http://localhost:3000 in a web browser.

Let me know what you think!

Top comments (3)

Collapse
 
rhymes profile image
rhymes

Hi Chuck, maybe you want to contribute to or keep an eye on this pull request about adding Docker support to dev.to: github.com/thepracticaldev/dev.to/...

Collapse
 
chuck_ha profile image
Chuck Ha

I'm not 100% convinced dev.to should be run in a container to tell you the truth. It really depends on what the devs want but I'll put in my two cents. Thanks for the encouragement!

Collapse
 
rhymes profile image
rhymes

Sure, but it could lower adoption and contribution if people can have that option. I'm not much of a Docker user myself...