ee.Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # syntax=docker/dockerfile:1.1.7-experimental
  2. # Base Go environment
  3. # -------------------
  4. FROM golang:1.15-alpine as base
  5. WORKDIR /porter
  6. RUN apk update && apk add --no-cache gcc musl-dev git
  7. COPY go.mod go.sum ./
  8. COPY /cmd ./cmd
  9. COPY /internal ./internal
  10. COPY /api ./api
  11. COPY /ee ./ee
  12. RUN --mount=type=cache,target=$GOPATH/pkg/mod \
  13. go mod download
  14. # Go build environment
  15. # --------------------
  16. FROM base AS build-go
  17. ARG version=production
  18. RUN --mount=type=cache,target=/root/.cache/go-build \
  19. --mount=type=cache,target=$GOPATH/pkg/mod \
  20. go build -ldflags="-w -s -X 'main.Version=${version}'" -tags ee -a -o ./bin/app ./cmd/app && \
  21. go build -ldflags '-w -s' -a -tags ee -o ./bin/migrate ./cmd/migrate && \
  22. go build -ldflags '-w -s' -a -tags ee -o ./bin/ready ./cmd/ready
  23. # Go test environment
  24. # -------------------
  25. FROM base AS porter-test
  26. RUN --mount=type=cache,target=/root/.cache/go-build \
  27. --mount=type=cache,target=$GOPATH/pkg/mod \
  28. go test ./...
  29. # Webpack build environment
  30. # -------------------------
  31. FROM node:lts as build-webpack
  32. WORKDIR /webpack
  33. COPY ./dashboard ./
  34. RUN npm i
  35. ENV NODE_ENV=production
  36. # TODO: remove this, but gets around https://github.com/webpack/webpack/issues/14532 for now
  37. ENV NODE_OPTIONS=--openssl-legacy-provider
  38. RUN npm run build
  39. # Deployment environment
  40. # ----------------------
  41. FROM alpine
  42. RUN apk update
  43. COPY --from=build-go /porter/bin/app /porter/
  44. COPY --from=build-go /porter/bin/migrate /porter/
  45. COPY --from=build-go /porter/bin/ready /porter/
  46. COPY --from=build-webpack /webpack/build /porter/static
  47. ENV DEBUG=false
  48. ENV STATIC_FILE_PATH=/porter/static
  49. ENV SERVER_PORT=8080
  50. ENV SERVER_TIMEOUT_READ=5s
  51. ENV SERVER_TIMEOUT_WRITE=10s
  52. ENV SERVER_TIMEOUT_IDLE=15s
  53. ENV COOKIE_SECRETS=secret
  54. ENV SQL_LITE=true
  55. ENV ADMIN_INIT=false
  56. EXPOSE 8080
  57. CMD /porter/migrate && /porter/app