Application to Docker (A2D) is a tool that is able to dockerize a single application.
docker run -v $PWD:/projectName utrecht/a2d:1.0.0 \
-projectName someProjectName -dockerfile /projectName/Dockerfile
creates a Dockerfile. If one does not have docker installed, one could issue:
./a2d -h
and the following output would be returned:
FROM golang:1.12.4-alpine as builder
COPY . ./someProjectName/
WORKDIR someProjectName
RUN adduser -D -g '' someProjectName && \
apk add git && \
CGO_ENABLED=0 go build && \
cp someProjectName /someProjectName && \
chmod 100 /someProjectName
FROM scratch
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder --chown=someProjectName:someProjectName /someProjectName /usr/local/someProjectName
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
USER someProjectName
ENTRYPOINT ["/usr/local/someProjectName"]