Golang app base environment
10K+
Images for docker containers:
go test.8080 port and run service command: /app/bin/service. Only thing you must do is copy binaries,
Makefile (if needed), migrations (if needed) and application default configuration.Common usage application Dockerfile:
FROM microparts/docker-golang-lint:latest as lint-env
COPY . /app
RUN make lint
# ----
FROM microparts/docker-golang-test:latest as test-env
# copy downloaded deps
COPY --from=lint-env ${GOPATH}/pkg/mod ${GOPATH}/pkg/mod
COPY . /app
RUN make test
# ----
FROM microparts/docker-golang-build:latest as build-env
# copy downloaded deps
COPY --from=lint-env ${GOPATH}/pkg/mod ${GOPATH}/pkg/mod
COPY . /app
RUN make all
# ----
FROM microparts/docker-golang-base:latest
COPY --from=build-env /app/bin/* /app/bin/
COPY --from=build-env /app/Makefile /app/
COPY --from=build-env /app/migrations/* /app/migrations/
COPY --from=build-env /app/configuration/defaults /app/configuration/defaults
If private packages are used, build it with Dockerfile below and command:
docker build -t <imagename>:<tag> --build-arg TOKEN="$(cat ~/.ci-token)" --build-arg PRIVATE_REPO="private.repo.url" .
FROM microparts/docker-golang-test:latest as test-env
ARG TOKEN
ARG PRIVATE_REPO
RUN git config --global url."https://ci-token:${TOKEN}@${PRIVATE_REPO}/".insteadOf 'https://${PRIVATE_REPO}/'
COPY . /app
RUN make test
Content type
Image
Digest
Size
3.8 MB
Last updated
over 6 years ago
docker pull microparts/docker-golang-base