Dockerfile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Build the a8m/envsubst binary, as it supports default values,
  2. # which the gnu envsubst (from gettext-base) does not.
  3. FROM golang:1.25.5-alpine AS envsubst_builder
  4. WORKDIR /build
  5. RUN go install github.com/a8m/envsubst/cmd/envsubst@latest
  6. FROM maven:3-amazoncorretto-21-debian AS base
  7. RUN apt-get update && apt-get install -y make git sqlite3 curl \
  8. && rm -rf /var/lib/apt/lists
  9. COPY --from=envsubst_builder /go/bin/envsubst /opt/envsubst
  10. RUN chmod +x /opt/envsubst
  11. RUN useradd --create-home node
  12. ENV MAVEN_OPTS="-Dmaven.repo.local=/app/.m2/repository"
  13. # pre-resolve Maven dependencies and plugins into the base image to limit
  14. # downstream `mvn` invocations hitting Maven Central on every CI build.
  15. COPY pom.xml /tmp/pom.xml
  16. RUN mvn -B --no-transfer-progress -f /tmp/pom.xml \
  17. dependency:go-offline \
  18. dependency:resolve-plugins \
  19. && chown -R node:node /app/.m2 \
  20. && rm /tmp/pom.xml
  21. FROM base AS builder
  22. COPY . /app
  23. WORKDIR /app
  24. RUN make package \
  25. # The name of the created jar contains the current version tag.
  26. # Rename it to a static path that can be used for copying.
  27. && find /app/target \
  28. -name 'writelatex-git-bridge*jar-with-dependencies.jar' \
  29. -exec mv {} /git-bridge.jar \;
  30. FROM amazoncorretto:21-alpine
  31. RUN apk add --update --no-cache bash git sqlite procps htop net-tools jemalloc util-linux
  32. ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
  33. RUN adduser -D node
  34. COPY --from=builder /git-bridge.jar /
  35. COPY --from=envsubst_builder /go/bin/envsubst /opt/envsubst
  36. RUN chmod +x /opt/envsubst
  37. COPY conf/envsubst_template.json envsubst_template.json
  38. COPY start.sh start.sh
  39. COPY server-pro-start.sh server-pro-start.sh
  40. RUN mkdir conf
  41. RUN chown node:node conf
  42. USER node
  43. CMD ["/start.sh"]