Dockerfile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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=/home/node/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. # Uses a stub source and test, since `dependency:go-offline` and `dependency:resolve-plugins`
  16. # miss lazy-loaded plugins (surefire, maven-assembly, etc.)
  17. COPY pom.xml /tmp/warmup/pom.xml
  18. RUN mkdir -p /tmp/warmup/src/main/java/stub /tmp/warmup/src/test/java/stub \
  19. && echo 'package stub; public class Stub {}' > /tmp/warmup/src/main/java/stub/Stub.java \
  20. && echo 'package stub; public class StubTest { @org.junit.Test public void noop() {} }' \
  21. > /tmp/warmup/src/test/java/stub/StubTest.java \
  22. && mvn -B --no-transfer-progress -f /tmp/warmup/pom.xml clean package \
  23. && chown -R node:node /home/node/repository \
  24. && rm -rf /tmp/warmup
  25. FROM base AS builder
  26. COPY . /app
  27. WORKDIR /app
  28. RUN make package \
  29. # The name of the created jar contains the current version tag.
  30. # Rename it to a static path that can be used for copying.
  31. && find /app/target \
  32. -name 'writelatex-git-bridge*jar-with-dependencies.jar' \
  33. -exec mv {} /git-bridge.jar \;
  34. FROM amazoncorretto:21-alpine
  35. RUN apk add --update --no-cache bash git sqlite procps htop net-tools jemalloc util-linux
  36. ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
  37. RUN adduser -D node
  38. COPY --from=builder /git-bridge.jar /
  39. COPY --from=envsubst_builder /go/bin/envsubst /opt/envsubst
  40. RUN chmod +x /opt/envsubst
  41. COPY conf/envsubst_template.json envsubst_template.json
  42. COPY start.sh start.sh
  43. COPY server-pro-start.sh server-pro-start.sh
  44. RUN mkdir conf
  45. RUN chown node:node conf
  46. USER node
  47. CMD ["/start.sh"]