Giter Club home page Giter Club logo

garden-docker-compose's Introduction

compose2garden sample application

React application with a NodeJS backend and a MongoDB database

This sample app serves as an example of migration from docker-compose to Garden. It is based on the react-express-mongodb example from the Awesome Compose repository.

The docker-compose configuration and source code have been left untouched, with only the Garden configuration files added to the project.

Project structure:

.
├── backend
│   ├── backend.garden.yml
│   ├── Dockerfile
│   ...
├── docker-compose.yaml
├── frontend
│   ...
│   ├── Dockerfile
│   ├── frontend.garden.yml
│   ...
│   └── project.garden.yml
├── mongo
│   └── mongo.garden.yml
└──README.md

The compose file defines an application with three services frontend, backend and db. When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file. Make sure port 3000 on the host is not already being in use.

Garden defines the same services but deploys the application on a local Kubernetes cluster, make sure it's running before deploying. The project is configured to create two ingresses from which the services are available:

Deploy the project

Deploy with garden

Note: you need to have a running Kubernetes cluster on your local machine.

$ garden deploy
Deploy 🚀 

Using environment default.default

✔ providers                 → Getting status... → Cached
   ℹ Run with --force-refresh to force a refresh of provider statuses.
✔ mongo                     → Getting build status for v-4e4b9e4d48... → Already built
✔ backend                   → Getting build status for v-64f4cdb8df... → Already built
✔ mongo                     → Deploying version v-5e8e8da229... → Done (took 3.4 sec)
   ℹ mongo                     → Resources ready
✔ frontend                  → Getting build status for v-f6dbf8b6ea... → Already built
✔ backend                   → Deploying version v-f8ca19f295... → Done (took 3.1 sec)
   ℹ backend                   → Resources ready
   → Ingress: http://backend.compose2garden.local.app.garden
✔ frontend                  → Deploying version v-ad031cb91f... → Done (took 25.8 sec)
   ℹ frontend                  → Resources ready
   → Ingress: http://compose2garden.local.app.garden

Done! ✔️ 

Start Garden in sync mode

$ garden deploy --sync
Good morning! Let's get your environment wired up...

Using environment default.default

✔ providers                 → Getting status... → Cached
   ℹ Run with --force-refresh to force a refresh of provider statuses.
✔ mongo                     → Getting build status for v-4e4b9e4d48... → Already built
✔ backend                   → Getting build status for v-64f4cdb8df... → Already built
✔ frontend                  → Getting build status for v-f6dbf8b6ea... → Already built
ℹ backend                   → Syncing ./ to /usr/src/app in Deployment/backend (one-way-replica)
✔ backend                   → Connected to sync target /usr/src/app in Deployment/backend
✔ backend                   → Completed initial sync from ./ to /usr/src/app in Deployment/backend
✔ frontend                  → Connected to sync target /usr/src/app/src in Deployment/frontend
✔ frontend                  → Completed initial sync from ./src to /usr/src/app/src in Deployment/frontend
✔ mongo                     → Deploying version v-5e8e8da229... → Already deployed
   → Forward: localhost:27017 → mongo:27017 (db)
ℹ frontend                  → Syncing ./src to /usr/src/app/src in Deployment/frontend (one-way-replica)
✔ backend                   → Deploying version v-f8ca19f295... → Already deployed
   → Ingress: http://backend.compose2garden.local.app.garden
   → Forward: http://localhost:3000 → backend:3000 (http)
✔ frontend                  → Deploying version v-ad031cb91f... → Already deployed
   → Ingress: http://compose2garden.local.app.garden
   → Forward: http://localhost:60523 → frontend:3000 (http)

🕑  Waiting for code changes...

Deploy with docker-compose

$ docker-compose up -d
Creating network "react-express-mongodb_default" with the default driver
Building frontend
Step 1/9 : FROM node:13.13.0-stretch-slim
 ---> aa6432763c11
...
Successfully tagged react-express-mongodb_app:latest
WARNING: Image for service app was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating frontend        ... done
Creating mongo           ... done
Creating app             ... done

garden-docker-compose's People

Contributors

10ko avatar vvagaytsev avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

garden-docker-compose's Issues

[Question] How to config for local and production

How to separate between local vs prod, using kustomize?

Currently there are local and prod folders (from cookiecutter-django):

compose/local/django/Dockerfile
compose/prod/django/Dockerfile

so do we make django.garden.yml in each folder?

But only one for Traefik:

compose/prod/traefik/Dockerfile

Or we don't need to define Dockerfile for Traefik and let Garden provide its own Ingress?
This tool also helps with debugging or misconfiguration? As it is often not known until when we kubectl apply that something is missing and frustrating to not able to resolve in a docker-compose.yml file: Django pods are getting 401 Unauthorized when MongoDB and Traefik are running?

It will be great if it hints how to suggest ways to resolve things like Secret not found.

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.