Dockerfile Language Type
Dockerfile Type Recognition Strategy
There is a
Dockerfile file in the main code directory. Kato will recognize the code language type as Dockerfile. This strategy has the highest priority. When the code complies with other language type recognition strategies at the same time, Dockerfile is still the main priority.
The source code recognized as the Dockerfile type will be mirrored using a command similar to
docker build -t xxx/xxx ., so this method is the most flexible source code compilation method, which can theoretically be applied to the support of all development languages (if Docker is supported).
The build process supports docker multi-stage (multi-stage build) and ARG parameter specification.
Dockerfile is a script composed of a series of commands and parameters. These commands are applied to the base image and finally create a new image.
Kato will read the following parameters defined in the Dockerfile during the source code inspection phase:
|ENV||Environment Variables||Recognized as Service Environment Variable Configuration|
|ARG||Build Parameters||Recognized as Build Settable Parameter Configuration|
|EXPOSE||Expose Ports||Port Configuration Recognized as Services|
|VOLUME||Persistent storage||Shared persistent storage configuration identified as a service|
The definition of Dockerfile is detailed in the official document: https://docs.docker.com/engine/reference/builder/
Here is a use case for Dockerfile to compile and deploy Golang source code:
FROM muninn/glide:alpine AS build-env ADD . /go/src/app WORKDIR /go/src/app RUN glide install RUN go build -v -o /go/src/app/app-server FROM alpine RUN apk add -U tzdata RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime COPY --from=build-env /go/src/app/app-server /usr/local/bin/app-server EXPOSE 80 CMD ["app-server"]