ee.Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # syntax=docker/dockerfile:1.1.7-experimental
  2. # Base Go environment
  3. # -------------------
  4. FROM golang:1.17-alpine as base
  5. WORKDIR /porter
  6. RUN apk update && apk add --no-cache gcc musl-dev git protoc
  7. COPY go.mod go.sum ./
  8. COPY /cmd ./cmd
  9. COPY /internal ./internal
  10. COPY /api ./api
  11. COPY /ee ./ee
  12. COPY /scripts ./scripts
  13. COPY /provisioner ./provisioner
  14. RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
  15. RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
  16. RUN --mount=type=cache,target=$GOPATH/pkg/mod \
  17. go mod download
  18. # Go build environment
  19. # --------------------
  20. FROM base AS build-go
  21. # build proto files
  22. RUN sh ./scripts/build/proto.sh
  23. ARG version=production
  24. RUN --mount=type=cache,target=/root/.cache/go-build \
  25. --mount=type=cache,target=$GOPATH/pkg/mod \
  26. go build -ldflags="-w -s -X 'main.Version=${version}'" -tags ee -a -o ./bin/app ./cmd/app && \
  27. go build -ldflags '-w -s' -a -tags ee -o ./bin/migrate ./cmd/migrate && \
  28. go build -ldflags '-w -s' -a -tags ee -o ./bin/ready ./cmd/ready
  29. # Go test environment
  30. # -------------------
  31. FROM base AS porter-test
  32. RUN --mount=type=cache,target=/root/.cache/go-build \
  33. --mount=type=cache,target=$GOPATH/pkg/mod \
  34. go test ./...
  35. # Webpack build environment
  36. # -------------------------
  37. FROM node:16 as build-webpack
  38. WORKDIR /webpack
  39. COPY ./dashboard ./
  40. RUN npm install -g npm@8.1
  41. RUN npm i --legacy-peer-deps
  42. RUN npm run build
  43. # Deployment environment
  44. # ----------------------
  45. FROM alpine
  46. RUN apk update
  47. COPY --from=build-go /porter/bin/app /porter/
  48. COPY --from=build-go /porter/bin/migrate /porter/
  49. COPY --from=build-go /porter/bin/ready /porter/
  50. COPY --from=build-webpack /webpack/build /porter/static
  51. ENV DEBUG=false
  52. ENV STATIC_FILE_PATH=/porter/static
  53. ENV SERVER_PORT=8080
  54. ENV SERVER_TIMEOUT_READ=5s
  55. ENV SERVER_TIMEOUT_WRITE=10s
  56. ENV SERVER_TIMEOUT_IDLE=15s
  57. ENV COOKIE_SECRETS=secret
  58. ENV SQL_LITE=true
  59. ENV ADMIN_INIT=false
  60. EXPOSE 8080
  61. CMD /porter/migrate && /porter/app