Git Product home page Git Product logo

dup's Introduction

dup: local Docker web development

Declaratively define and run stateful Docker containers for web development.

Usage:
  dup up                   Starts the containers
  dup down                 Stops and removes the containers
  dup init                 Initialises the "-data" container
  dup status               Not yet implemented
  dup build [--no-cache]   Builds the web container's image
  dup (-h | --help)        Prints this help message
  dup --version            Prints the installed version

dup is a tiny wrapper over Docker that loads a declarative JSON file for a given project to manage containers (especially stateful database containers) in a sane way. It was created due to frustration with docker-compose and it's issues with volume-only containers: a prerequisite for easy local web development. Three containers are created, prefixed with your declared project name (no defaulting to folder names here!): -web, -db and -data.

New features

v0.3.9

This release added support for the official PostgreSQL Docker image, to allow the usage of version 9.5 (for it's jsonb support). In the future, you will be able to specify which point release of PostgreSQL your project needs.

v0.3.7

The main new feature in v0.3.7 is the addition of --build-arg env=dev to the dup build command. This is a temporary measure until I expose build-args to the user via the .up.json file. This feature means you need to have this line in your base Dockerfile:

ARG env

This is the bare minimum. You will likely want to instead do the following:

ARG env=prod

This will default the argument to prod, and fix the One or more build-args [env] were not consumed, failing build. error that will otherwise be triggered. An example of how to leverage this feature to allow for a singular production Dockerfile that has developer tools added on top, assuming two files: conf/start.prod.sh which is the standard entry-point, and conf/start.dev.sh which is the development entry-point that adds extra tools is as follows:

###
# This is both a test of Skate as a tool, as well as build-args for Docker
##
FROM studionone/node6:latest

# Use a different entrypoint for development vs production
ARG env=prod
ADD conf/start.$env.sh /start.sh
RUN chmod +x /start.sh

ADD code /app
WORKDIR /app
RUN npm install

EXPOSE 8080

ENTRYPOINT /start.sh

.up.json

In the root of your project, next to the Dockerfile, you will need a JSON file .up.json, that follows this format:

{
    "project": "project-name-here",
    "port": "host:container",
    "db": {
        "type": "mysql-or-postgres",
        "name": "database-name",
        "pass": "password-for-admin-or-root-user"
    }
}

Optional config

All optional configs are keys on the top level config object.

Specify a Dockerfile (other than the root Dockerfile):

"dockerfile": "Dockerfile.local"

Specify environment variables for the web container:

"env": {
    "KEY_ONE": "valueOne",
    "KEY_TWO": "valueTwo",
    "VIRTUAL_HOST": "example.docker"
}

Specify a different code directory volume map (host directory is automatically prepended with current directory). By default, this is set to code:/var/www:

"volume": "relative-host-dir:/absolute/container/dir"

Code

Your code is mounted as a volume into the -web container from the code/ directory in the root of your project. This can be any language, though PHP and Node.js are the most tested at this point in time, with the studionone/apache-php5:base and studionone/nginx-php5:base base images.

Databases

Currently, dup handles MySQL, using the tutum/mysql:latest Docker image. PostgreSQL is now supported, via the sameersbn/postgresql:latest Docker image. Persistence of your database is handled by leveraging a "volume-only" container, which ensures that your database persists across destruction of the container. To completely destroy your database, remove the .up.state file and docker rm the -data container.

The database user that is setup by default under tutum/mysql is admin, and the password for that user is declared in .up.json.

Alternatively, to not use a database, set the db object to:

"db": {
  "type": "none"
}

Troubleshooting

OSX: could not import: pcre_free_study

You'll need to install a newer version of the pcre library: brew install pcre should fix this issue.

Building

OS X

You'll need make, nim and it's package manager nimble. Clone the repository, run nimble install, and then make. The binary will be in ./build.

Linux

If you're building natively, then you can follow the same instructions as OSX. If you're running OSX but want to cross-compile, run make linux.

Release builds

$ make release

Linux builds are -d:release by default.

License

MIT. See LICENSE.md for details.

dup's People

Contributors

girvo avatar

Watchers

James Cloos avatar Greg Beaven 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.