Coder Social home page Coder Social logo

example-docker's Introduction

example-docker

An example repository to demonstrate Pantsbuild's experimental Docker support.

See pantsbuild.org for much more detailed documentation.

This is only one possible way of laying out your project with Pantsbuild. See pantsbuild.org/docs/source-roots#examples for some other example layouts.

Note: Pantsbuild and Pants will be used interchangebly, they refer to the same thing, the Pants Build System.

Running Pantsbuild

You run Pants goals using the pants launcher binary, which will bootstrap the version of Pants configured for this repo if necessary.

See here for how to install the pants binary.

Use pants --version to see the version of Pants configured for the repo (which you can also find in pants.toml).

Goals

Pants commands are called goals. You can get a list of goals with

pants help goals

Most goals take arguments to run on. To run on a single directory, use the directory name with : at the end. To recursively run on a directory and all its subdirectories, add :: to the end.

For example:

pants lint src/python/hello_world: src/docker::

You can run on all changed files:

pants --changed-since=HEAD lint

You can run on all changed files, and any of their "dependees":

pants --changed-since=HEAD --changed-dependees=transitive test

Example Goals

Try these out in this repo!

Run a Docker image

pants run src/docker/hello_world:python
pants run src/docker/hello_world:shell

List targets

pants list ::  # All targets.
pants list 'src/**/*.py'  # Just targets containing Python code.

Run linters, formatters and fixers

pants fix lint ::  # First format and fix, then lint all sources.

Count lines of code

pants count-loc '**/*'

Dynamic image tag

The documentation for dynamic image tagging has an example implementation here showcasing how it works.

DYNAMIC_TAG=$(date +%Y.%m.%d) pants package src/docker/dynamic_tags

10:47:43.89 [INFO] Completed: Building docker image dynamic_tags:1.0-2022.03.15
10:47:43.89 [INFO] Built docker image: dynamic_tags:1.0-2022.03.15
Docker image ID: sha256:8f6922aec0de7c147862672fa2cef4bd72f51e02b5a06089b0383355410b79f2

DYNAMIC_TAG=$(date +%Y.%m.%d) pants run src/docker/dynamic_tags
10:47:43.89 [INFO] Completed: Building docker image dynamic_tags:1.0-2022.03.15
  ____
| demo |
  ====
    \
     \
       ^__^
       (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||

example-docker's People

Contributors

alextereshenkov avatar benjyw avatar eric-arellano avatar huonw avatar kaos avatar sureshjoshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

example-docker's Issues

Container not re-used on code change

I have been trying this example and wanted to check whether hot code reloading also works when running the Docker container with pants. What I noticed is, that on every code change a new container is run. For a lot of code changes, this would spin up a lot of containers. Am I missing something to be configured?

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.