ee.Dockerfile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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:latest as build-webpack
  32. WORKDIR /webpack
  33. COPY ./dashboard ./
  34. RUN npm i
  35. ENV NODE_ENV=production
  36. RUN npm run build
  37. # Deployment environment
  38. # ----------------------
  39. FROM alpine
  40. RUN apk update
  41. COPY --from=build-go /porter/bin/app /porter/
  42. COPY --from=build-go /porter/bin/migrate /porter/
  43. COPY --from=build-go /porter/bin/ready /porter/
  44. COPY --from=build-webpack /webpack/build /porter/static
  45. ENV DEBUG=false
  46. ENV STATIC_FILE_PATH=/porter/static
  47. ENV SERVER_PORT=8080
  48. ENV SERVER_TIMEOUT_READ=5s
  49. ENV SERVER_TIMEOUT_WRITE=10s
  50. ENV SERVER_TIMEOUT_IDLE=15s
  51. ENV COOKIE_SECRETS=secret
  52. ENV SQL_LITE=true
  53. ENV ADMIN_INIT=false
  54. EXPOSE 8080
  55. CMD /porter/migrate && /porter/app