Coder Social home page Coder Social logo

go-dotenv-dockerfile's Introduction

Gitpod Ready-to-Code Release Build Docker Build

How to

This simple command line will provide you option for render DOTENV with source from .env file. Best to describe it is to show example - files for this example you can find in example directory.

First of all our files, first Dockerfile.env that will be our template:

FROM node:10.17.0 AS build-env
WORKDIR /opt/app
COPY package*.json ./
RUN npm install
COPY . .

FROM gcr.io/distroless/nodejs
COPY --from=build-env /opt/app /opt/app
WORKDIR /opt/app
EXPOSE 8080

DOTENV # check at https://github.com/kivio/go-dotenv-dockerfile

CMD ["app.js"]

Second .env file with out variables:

SERVICE_NAME='my-nodejs-app'
SERVICE_CONF='config.app'
PORT='8080'

Now we will run our command. By default it use files with names as we have here and produce Dockerfile. Output will look like:

FROM node:10.17.0 AS build-env
WORKDIR /opt/app
COPY package*.json ./
RUN npm install
COPY . .

FROM gcr.io/distroless/nodejs
COPY --from=build-env /opt/app /opt/app
WORKDIR /opt/app
EXPOSE 8080

ENV SERVICE_NAME my-nodejs-app
ENV SERVICE_CONF config.app
ENV PORT 8080

CMD ["app.js"]

To configure file names let's look to help of our program:

Usage of ./dotenv2dockerfile:
  -dockerfile-file string
        path to Dockerfile before rendering (default "Dockerfile.env")
  -dotenv-file string
        path to .env file or it different name (default ".env")
  -output string
        path to output Dockerfile (default "Dockerfile")

How Docker image works

To work with this tool as container (usage - as step for dockerized CI/CD) you need to mount few things:

  • first of all file with dotenv configuration
  • second file with Dockerfile template
  • and last one - volume where you output should be produced

go-dotenv-dockerfile's People

Contributors

kivio avatar

Watchers

 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.