github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/Dockerfile (about)

     1  # build image to construct the binary
     2  FROM golang:1.14.6-alpine AS builder
     3  LABEL maintainer="sparkle_pony_2000@qri.io"
     4  
     5  RUN apk update \
     6      && apk upgrade \
     7      && apk add --no-cache \
     8         bash git make openssh
     9  
    10  # build environment variables:
    11  #   * enable go modules
    12  #   * use goproxy
    13  #   * disable cgo for our builds
    14  #   * ensure target os is linux
    15  ENV GO111MODULE=on \
    16      GOPROXY=https://proxy.golang.org \
    17      CGO_ENABLED=0 \
    18      GOOS=linux
    19  
    20  # add sorce code to a "/qri" directory on the build image
    21  ADD . /qri
    22  # use that directory for working
    23  WORKDIR /qri
    24  
    25  # build using make command
    26  RUN make build
    27  
    28  # *** production image ***
    29  # use alpine as base for smaller images
    30  FROM alpine:latest as production
    31  LABEL maintainer="sparkle_pony_2000@qri.io" 
    32  
    33  # create directories for IPFS & QRI, setting proper owners
    34  RUN mkdir -p $QRI_PATH /app
    35  
    36  WORKDIR /app
    37  
    38  # Copy our static executable from the builder image
    39  COPY --from=builder /qri/qri /bin/qri
    40  
    41  # need to update to latest ca-certificates, otherwise TLS won't work properly.
    42  # Informative:
    43  # https://hackernoon.com/alpine-docker-image-with-secured-communication-ssl-tls-go-restful-api-128eb6b54f1f
    44  RUN apk update \
    45      && apk upgrade \
    46      && apk add --no-cache \
    47         ca-certificates \
    48      && update-ca-certificates 2>/dev/null || true
    49  
    50  # Set binary as entrypoint
    51  # the setup flag initalizes ipfs & qri repos if none is mounted
    52  # the migrate flag automatically executes any necessary migrations
    53  # the no-prompt flag disables asking for any user input, reverting to defaults
    54  CMD ["qri", "connect", "--setup", "--migrate", "--no-prompt"]