Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.

Using Docker

Christophe Sicard edited this page Sep 4, 2018 · 24 revisions

CODEKRAFT COOK MAKER

Using Docker

The Docker Cook Maker produces 4 containers via docker-compose :

  • postgres : the postgres container providing full access to a local postgres database
  • redis : the redis container providing full access to a local redis database
  • api : the container in charge to execute the rails server for the generated api
  • frontend : the container in charge to execute de node server for the generated frontend

Docker Compose

Make docker accessible for non-root users

For linux based developpers, we need to give access to docker for non-root user. Either you will need to add sudo to all of the commands below.

# Add the docker group if it doesn't already exist
sudo groupadd docker
# Add the connected user "$USER" to the docker group. Change the user name to match your preferred user if 
# you do not want to use your current user
sudo gpasswd -a $USER docker

Either do a newgrp docker or log out/in to activate the changes to groups.

You can test if all is ok by running :

docker run hello-world

Quick install and example creation

For a first install or an example test, just follow this commands.

# Cloning Cook Maker locally
git clone https://github.com/TheRealCodeKraft/cook-maker
# Cook a new example app
./cook-maker/docker/cook -a example
# Go to the fresh example folder 
cd example
# Build the example app
./tools/cook-build
# Launch the example app
./tools/cook-up -d
# Create db Schema
./tools/cook-db
# Seed the database
./tools/cook-seed

After that, just connect to http://localhost:3002 and magic will appear !

Step by Step install

Clone the repo

# Cloning Cook Maker locally
git clone https://github.com/TheRealCodeKraft/cook-maker

Create a fresh app

# Build the docker image
./cook-maker/docker/cook -a example

or

docker build -t cook-maker /path_to_cook-maker/docker
# Go to your projet base camp
cd ~/Projects
# Run the cook maker
docker run -it -v $(pwd):/build -e name=example --name cook-maker-example cook-maker

Just replace example with your own app name.

It will results on a directory called with your app name (e.g. example) containing two folders named api and frontend.

Launch app

For launching a cooked app, go to your projet folder with cd ~/Projects/example and then :

Build it
# Build dockers containers
./tools/cook-build

or

docker-compose -f tools/docker-compose.yml build
Launch it
# Launch the whole app
./tools/cook-up

or

docker-compose -f tools/docker-compose.yml up
Create and Seed Database

Attention The app must be up to create and seed database !

For first launch, you will create the base database and seed id. If you are linux based developper, just use ./cook-db and ./cook-seed,else :

# Create the database
./tools/cook-db

or

docker-compose -f tools/docker-compose.yml run api rake db:migrate
# Seed the database
./tools/cook-seed

or

docker-compose -f tools/docker-compose.yml run api rake db:seed
Accessing the front

You will be now able to connect on http://localhost:3002.

A default admin user is set up. You can find the defaut data in api/.codekraftrc.