GithubHelp home page GithubHelp logo

alexboor / rewrite-docker-image-content Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3 KB

The way how can rewrite files inside a docker container while building image for deferent environment

HTML 100.00%

rewrite-docker-image-content's Introduction

How to rewrite content in a container?

A small example of how we still let dev-squads build their containers, and at the same time ops-team can prepare containers for production without actual build whole application without all necessary tools and dependencies.

To develop this way can clearly split the delivery process to different environments without rebuild containers, control configurations for each environment and automate all stages if CD process.

If Develop it even more then can implement auto-rotating secrets/certificates in production environment in automaticall basis.

DEV part

Small example based on Nginx application, which returns index.html for any request.

Let assume that this is our application. All necessary steps performs from Dockerfile.dev. Basically there we copy configs and index.dev.html to index.html to detect container version.

To build use:

docker build -f Dockerfile.dev -t nginx:dev .

then we get local docker image tagged as nginx:dev

If run it:

docker run -p 80:80 nginx:dev

and open browser at http://localhost/ we can see DEVELOPMENT ENVIRONMENT caption on the screen - the content from index.dev.html file.

Could say that dev version of our application built successfully.

Go next?

QA part

Assume that our image ready for QA environment. On QA we need different databases with seeded data, most probably we need different certificates to interact with other systems in QA contour etc. In other words, we need to update some files and configuration parameters for application inside the container. Let's skip configurations as it should come from ENV and it easy to implement. But how to deal with files we need put inside the container? Actually it also pretty easy - check Dockerfile.qa.

docker build -f Dockerfile.qa -t nginx:qa .

docker run -p 80:80 nginx:qa

Open it in a browser and get QA caption on the screen.

We had to update the index.html file in the container but we didn't touch anything else. Not necessary to install all toolset and bunch of libraries to build application container as developers do. Only operation manipulations. Easy?

Production part

Do the same approach. But here at this stage we already have tested not only application together with configuration set, but also the approach. So if it comes from dev to QA with change only necessary configuration, then we could say that this configuration set work and updating automatically.

docker build -f Dockerfile.prod -t nginx:prod .

docker run -p 80:80 nginx:prod

and get 'production' caption on the page.

Developers doing their job, ops doing their job, everybody happy.

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.