All Projects → orisano → targd

orisano / targd

Licence: MIT license
targd is multistage build helper

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

targd

targd is multistage build helper. targd outputs dependent stage of the specified target stage. (includes target stage)

Installation

go get github.com/orisano/targd

How to use

$ targd
  -f string
    	Dockerfile path (default "Dockerfile")
  -o string
    	generated Dockerfile path (default "-")
  -target string
    	target stage name (required)
$ targd -target test | docker build -f - .

or

$ docker run -v $(PWD):/host orisano/targd -f /host/Dockerfile -target production

Example

# ./Dockerfile
FROM alpine:3.8 as builder
COPY ./depfile ./lockfile ./
RUN install_cmd
COPY . .
RUN build_cmd

FROM builder as test
RUN test_cmd

FROM alpine:3.8 as runtime
COPY --from=builder /bin/app /bin/app
ENTRYPOINT ["/bin/app"]
CMD ["--help"]
$ targd -target test
FROM alpine:3.8 as builder
COPY ./depfile ./lockfile ./
RUN install_cmd
COPY . .
RUN build_cmd

FROM builder as test
RUN test_cmd
$ targd -target runtime
FROM alpine:3.8 as builder
COPY ./depfile ./lockfile ./
RUN install_cmd
COPY . .
RUN build_cmd

FROM alpine:3.8 as runtime
COPY --from=builder /bin/app /bin/app
ENTRYPOINT ["/bin/app"]
CMD ["--help"]

Author

Nao Yonashiro (@orisano)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].