Code Monkey home page Code Monkey logo

docker-dev-environment's Introduction

Docker development environment

Contains the development environment required to build, run and develop the Foodkit API and consumer website.

Getting started

Install Docker. You can get it for Windows, Mac OSX, Ubuntu and a range of other *nix distributions.

To get started, you should place this repository in the parent folder of the api and consumer-web projects.

That is, your folder structure should be as such:

/parent-folder
  |- api
  |- consumer-web
  |- docker-dev-environment

You'll need to prepare both codebases by running composer install in each folder. After this, you can go ahead and bring up the Docker containers:

cd docker-dev-environment
docker-compose up -d

You should now have an API server running on http://localhost:8888 and a consumer web server running on http://localhost:8889.

How do I...

...make code changes?

The scripts will add mount points on the containers that link directly back to the host file system. You can edit the files in the ../consumer-web and ../api folders and they will be instantly reflected inside the Docker containers.

...run migrations?

docker-compose exec api-app php artisan migrate --force

...connect to the database?

The Docker configuration will port-forward PostGRES to 54321 on your local machine. You can connect using:

psql -U postgres -h localhost -p 54321

...clear the cache?

The Redis container is shared between API and website, so you only need to do it once for both:

docker-compose exec api-app php artisan cache:clear

...tail the logs?

For the API:

docker-compose exec api-app tail -f storage/logs/laravel.log

... and the website:

docker-compose exec consumer-web-app tail -f storage/logs/laravel.log

...run the tests?

@TODO

There's currently no easy way to do this apart from manually bootstrapping and running phpunit via docker-compose exec....

Help! Something broke

You can check that all the processes are running as expected using the following command:

docker-compose ps

You should see a list of the containers:

                  Name                                 Command               State               Ports
------------------------------------------------------------------------------------------------------------------
dockerdevenvironment_api-app_1              php-fpm                          Up      9000/tcp
dockerdevenvironment_api-nginx_1            nginx -g daemon off;             Up      443/tcp, 0.0.0.0:8888->80/tcp
dockerdevenvironment_consumer-web-app_1     php-fpm                          Up      9000/tcp
dockerdevenvironment_consumer-web-nginx_1   nginx -g daemon off;             Up      443/tcp, 0.0.0.0:8889->80/tcp
dockerdevenvironment_database_1             docker-entrypoint.sh postgres    Up      0.0.0.0:54321->5432/tcp
dockerdevenvironment_redis_1                docker-entrypoint.sh redis ...   Up      0.0.0.0:32768->6379/tcp

Look at the "state" column. If any of them are not "Up" that's probably where you want to start. You can check the log for the container process using:

docker-compose logs api-app --follow

If all hope is lost, you can rebuild the containers:

# Stop and delete containers
docker-compose down

# Rebuild images:
docker-compose build

# Restart containers (daemonised):
docker-compose up -d

Contributing

See the list of open issues here.

docker-dev-environment's People

Contributors

coreymcmahon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.