ee.Dockerfile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 /provisioner ./provisioner
  13. COPY /scripts ./scripts
  14. RUN --mount=type=cache,target=$GOPATH/pkg/mod \
  15. go mod download
  16. # Go build environment
  17. # --------------------
  18. FROM base AS build-go
  19. # build proto files
  20. RUN sh ./scripts/build/proto.sh
  21. ARG version=production
  22. RUN --mount=type=cache,target=/root/.cache/go-build \
  23. --mount=type=cache,target=$GOPATH/pkg/mod \
  24. go build -ldflags="-w -s -X 'main.Version=${version}'" -tags ee -a -o ./bin/app ./cmd/app && \
  25. go build -ldflags '-w -s' -a -tags ee -o ./bin/migrate ./cmd/migrate && \
  26. go build -ldflags '-w -s' -a -tags ee -o ./bin/ready ./cmd/ready
  27. # Go test environment
  28. # -------------------
  29. FROM base AS porter-test
  30. RUN --mount=type=cache,target=/root/.cache/go-build \
  31. --mount=type=cache,target=$GOPATH/pkg/mod \
  32. go test ./...
  33. # Webpack build environment
  34. # -------------------------
  35. FROM node:16 as build-webpack
  36. WORKDIR /webpack
  37. COPY ./dashboard ./
  38. RUN npm install -g npm@8.1
  39. RUN npm i --legacy-peer-deps
  40. RUN npm run build
  41. # Deployment environment
  42. # ----------------------
  43. FROM alpine
  44. RUN apk update
  45. COPY --from=build-go /porter/bin/app /porter/
  46. COPY --from=build-go /porter/bin/migrate /porter/
  47. COPY --from=build-go /porter/bin/ready /porter/
  48. COPY --from=build-webpack /webpack/build /porter/static
  49. ENV DEBUG=false
  50. ENV STATIC_FILE_PATH=/porter/static
  51. ENV SERVER_PORT=8080
  52. ENV SERVER_TIMEOUT_READ=5s
  53. ENV SERVER_TIMEOUT_WRITE=10s
  54. ENV SERVER_TIMEOUT_IDLE=15s
  55. ENV COOKIE_SECRETS=secret
  56. ENV SQL_LITE=true
  57. ENV ADMIN_INIT=false
  58. EXPOSE 8080
  59. CMD /porter/migrate && /porter/app