Git Product home page Git Product logo

docker-base's Introduction

Reaction Docker Base Images

CircleCI

This repo contains general Docker images used by various Reaction Commerce projects. Refer to the specific image documentation.

Images:

Published Images

Every merge/push to trunk branch will rebuild all Dockerfiles and push them to DockerHub as part of the CircleCI workflow.

These are the published image tags:

Adding a New Image

In /images, add a new folder named whatever you want the image name to be. In that folder, add a subfolder for each version of the image. This could be based on a version of the FROM image, the version of a dependency that is installed in it, or whatever else makes sense for that image. Regardless, append -v1 to the version folder name so that changes can be made in the future and published with a new tag, even if the underlying version designator hasn't changed.

In each version folder, add a file named Dockerfile. In it, define the image you want to build. If you need to copy any scripts into your image and run them, put them in a subfolder named scripts alongside your Dockerfile. Alternatively, if multiple images need the same script, you can place it in /scripts at the project root. All files there are copied into the image-specific scripts folder before each image is built. To copy them into your image, add something like this line to your Dockerfile:

COPY ./scripts /usr/local/src/app-scripts

Building an Image

On your development computer, you can test building an image with this command:

./dockerfiles.sh build images/image-name/version/Dockerfile

Substitute the proper path to your Dockerfile.

If for some reason you want to test building all images, you can leave off the Dockerfile path:

./dockerfiles.sh build

Pushing an Image to DockerHub

The command ./dockerfiles.sh push will push all built images to DockerHub, but you need proper permissions. It's best to let CircleCI do this, which it does after every successful merge to trunk.

docker-base's People

Contributors

akarshit avatar aldeed avatar delagroove avatar focusaurus avatar griggheo avatar jhonsfran avatar kieckhafer avatar loan-laux avatar m5ingh avatar mikemurray avatar mohannarayana avatar rosshadden avatar zenweasel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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

docker-base's Issues

fix-volumes chowning to root

Hey Pete, everytime fix-volumes.sh runs it does a chown -R root:root .
all the files in my filesystem become owned by root
Fixing volume /app (before=1000:1000 after=0:0)โ€ฆโœ“
I know that's what it says it's doing, too, but it's not expected that it would make the files on my
host owned by root, right?

Change workdir to /app

As I understand it /app is pretty much the canonical mount path. The Docker docs use this path as an example in their Best practices for writing Dockerfiles page, and it is used in an overwhelming number of blog posts and articles. We use it in many of our projects but not our base image.

This will be an easy change but needs to be done as new revisions of our images, not editing the existing dockerfile revisions.

Consider semver build metadata instead of "-v1" suffixes

Not sure if how we are using the "-v" suffixes aligns exactly with semver build metadata, but in the spirit of using external standards, I'd point us to point 10 of semver. And I also just think the "v" should be only used strictly as a prefix and everything after it is the version, so having another random "v" in there is weird.

Entrypoint requires a specific mount path

The entrypoint script in the 12.14 base image requires the app to be mounted at /usr/local/src/app, and only runs npm install if this is the case.

The earlier images all ran npm install no matter what the mount path was, but after investigating why it turns out it was likely an unexpected bug. This is the relevant code from the earlier images:

if [[ -f /usr/local/src/app/yarn.lock ]]; then
  echo "(Using Yarn because there is a yarn.lock file)"
  su-exec node yarn install
else
  su-exec node npm install --no-audit
fi

It's looking for yarn.lock in the required mount path, and if not found it runs npm install regardless of where the mount path is. Based on this code it seems the expectation was to only install npm dependencies at the one mount path as well, but some of our other projects were relying on this. Thus when it was "fixed" we had regressions. https://xkcd.com/1172/

Ultimately the entrypoint script should not care where you mount your application. We should make it mount-agnostic.

Support npm private package installation

One of the problem I faced it was I had to create another image to support npm private packages installation. So I think it would be useful change this line

for something like:

ONBUILD COPY --chown=node:node package-lock.json LICENSE* .npmrc ./

That way people can define the file .npmrc like:
engine-strict=true
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

so when folks try to build a custom image they can do it by using something like this:
docker build -t $IMG:$TAG --build-arg NPM_TOKEN=TOKEN .

Volume owner research

  • It looks like https://github.com/just-containers/s6-overlay solves the volume owner problem in much the same general approach we do, but they read a configuration file for the directories. Interesting to study but at the moment I think fix-volumes.sh is better for us since it needs no explicit configuration. If, however, we hit issues and we think derived images will need to explicitly list their volume mounts, we might look at s6-overlay specifically their fix-attrs script

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.