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.

Compilation Principle

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 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:

Parameter typeNameDescription
ENVEnvironment VariablesRecognized as Service Environment Variable Configuration
ARGBuild ParametersRecognized as Build Settable Parameter Configuration
EXPOSEExpose PortsPort Configuration Recognized as Services
VOLUMEPersistent storageShared persistent storage configuration identified as a service

The definition of Dockerfile is detailed in the official document:

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
CMD ["app-server"]

Complete Sample Code