Configuring and running services for Webmaker is a real pain in the ass.
(Webmaker services = Webmaker API, Webmaker ID, and Webmaker LoginAPI)
There's database and caching services to install and configure, npm dependencies to install, native NodeJS bindings to compile (sorry, Windows), and database scripts/migrations to run. This makes life difficult for many. Particularly those who don't handle these things on a day to day basis, like front-end focused developers or designers. I wanted to make life easier for them, so I took some time to fix that problem.
I decided to fix this problem using Docker. Docker is a platform for building self contained applications that have their own filesystem, runtimes, system libraries, and more. What this basically means is that you can build a Docker image once, and expect it to run anywhere (...that can run Docker).
Webmaker-Docker is a new repo I've created to contain everything you need to run Webmaker Services, without needing to install anything except git, Docker, and Docker Compose. That's right, no need to install NodeJS, npm, Postgres, MySQL, SQLite, Redis. No need to run npm install
or bower install
. We're finally living the dream, folks.
This development will enable something we've never had before: The ability to give front end devs and designers simple and easy access to services they can use when prototyping and developing new features. It's even possible to create dockerized feature branches for team mates to use new service features to develop front end parts in paralell! (Follow up post on that another time)
How To Run
Okay, so you're super excited about this, but not sure exactly what to do next. Let's go over the set-up (subject to changes :P). I should note that docker will automatically download container images from Docker Hub, so make sure you've got a decent internet connection or time (or both) - but don't worry, this will only happen the first time.
- Install Docker and Docker Compose (available for Linux, Mac and Windows) - Installation instructions
- Clone the git repository:
git clone git@github.com:cadecairos/webmaker-docker
- Go to the
data-services
directory and rundocker-compose up -d
to start the database services Webmaker needs.
- They're started in the background by passing the
-d
flag, omit it if you want to see container logs.
- Go to the
services
directory and rundocker-compose up -d
to start the Webmaker services.
- omit -d to see logs from the Applications (helpful for debugging)
- To shut down the containers when they're detached, go to the two directories mentioned above and run
docker-compose stop
, otherwise,ctrl-c
does the trick.
Now what?
That's up to you! You've got fully functional services running that you can use to do whatever you please. Wanna prototype a new feature or site that depends on one of these services? Go for it! Here's a rundown on what services are exposed, and where:
- Postgres is listening on localhost:5432
- username: 'webmaker'
- password: 'webmaker'
- database: 'webmaker'
- MariaDB is listening on localhost:3306
- username: 'wmlogin'
- password: 'wmlogin'
- database: 'wmlogin'
- root password :'root_wmlogin'
- Redis is listening on localhost:6379
- There aren't any credentials to worry about
- Webmaker API is listening on localhost:2015
- Webmaker ID is listening on localhost:1234
- there's a client and secret already in the database for you
- client_id: 'webmaker'
- secret: 'webmaker'
- all grant types and response types allowed.
- redirect_url is 'example.com' - You can manually change it or insert a new one if you desire
- there's a client and secret already in the database for you
- Legacy Login is listening on localhost:3000, but don't touch it if you know what's good for you.
Let's get technical
Let's talk about how this all is put together. The base of all this magic is two files known as Compose files. Compose files use YAML to define a collection of Docker Images to build/download/execute. It defines what ports to expose, what kind of networking to use and lets you pull in env files to configure the applications running within.
Here's the data-services Compose file:
Here's the Webmaker services Compose file:
Each of the services is put together with a Dockerfile. Dockerfiles are text files that automate the creation of images. Here's the Dockerfile for Webmaker API:
There's plenty more to find in the repo, so go take a look!