|
1 | 1 | # Docker for Convex
|
2 | 2 |
|
3 |
| -# FROM maven:3.9.9-eclipse-temurin-22 AS build |
4 |
| -# #ENV HOME=/home/convex |
5 |
| -# WORKDIR $HOME |
6 |
| -# ADD . $HOME |
7 |
| -# RUN mvn clean package |
| 3 | +# Build stage |
| 4 | +FROM maven:3.9.9-eclipse-temurin-22-jammy AS build |
| 5 | +WORKDIR /build |
| 6 | +COPY . . |
| 7 | +RUN mvn clean install -DskipTests |
8 | 8 |
|
9 | 9 | # Run stage
|
| 10 | +FROM eclipse-temurin:22-jre-alpine AS run |
| 11 | + |
| 12 | +# Add labels |
| 13 | +LABEL org.opencontainers.image.title="Convex" |
| 14 | +LABEL org.opencontainers.image.description="Convex Peer Node" |
| 15 | +LABEL org.opencontainers.image.source="https://github.com/Convex-Dev/convex" |
| 16 | + |
| 17 | +# Create non-root user |
| 18 | +RUN addgroup -S convex && adduser -S convex -G convex |
| 19 | + |
| 20 | +# Set environment variables |
| 21 | +ENV HOME=/home/convex \ |
| 22 | + CONVEX_HTTP_PORT=8080 \ |
| 23 | + CONVEX_BINARY_PORT=18888 \ |
| 24 | + CONVEX_HTTPS_PORT=443 |
10 | 25 |
|
11 |
| -FROM eclipse-temurin:22-jdk-alpine AS run |
12 |
| -ENV HOME=/home/convex |
13 | 26 | WORKDIR $HOME
|
14 |
| -COPY ./convex-integration/target/convex.jar convex.jar |
15 | 27 |
|
16 |
| -##### Expose ports. These can be mapped to host ports |
| 28 | +# Copy application jar from build stage |
| 29 | +COPY --from=build /build/convex-integration/target/convex.jar convex.jar |
17 | 30 |
|
18 |
| -# Convex binary protocol port |
19 |
| -EXPOSE 18888 |
| 31 | +# Set proper permissions |
| 32 | +RUN chown -R convex:convex $HOME && \ |
| 33 | + chmod 500 convex.jar |
20 | 34 |
|
21 |
| -# HTTP port. Can be used for an HTTPS proxy |
22 |
| -EXPOSE 8080 |
| 35 | +# Create and set permissions for volumes |
| 36 | +RUN mkdir -p /etc/convex/keystore && \ |
| 37 | + chown -R convex:convex /etc/convex |
23 | 38 |
|
24 |
| -# HTTPS port. Usable if server has a certificate |
25 |
| -EXPOSE 443 |
| 39 | +# Switch to non-root user |
| 40 | +USER convex |
26 | 41 |
|
| 42 | +# Expose ports |
| 43 | +EXPOSE $CONVEX_BINARY_PORT |
| 44 | +EXPOSE $CONVEX_HTTP_PORT |
| 45 | +EXPOSE $CONVEX_HTTPS_PORT |
| 46 | + |
| 47 | +# Define volumes |
27 | 48 | VOLUME ["/etc/ssl/certs"]
|
28 | 49 | VOLUME ["/etc/convex/keystore"]
|
29 | 50 |
|
| 51 | +# Health check |
| 52 | +HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \ |
| 53 | + CMD wget --no-verbose --tries=1 --spider http://localhost:${CONVEX_HTTP_PORT}/api/v1/status || exit 1 |
| 54 | + |
30 | 55 | ENTRYPOINT ["java", "-jar", "convex.jar", "peer", "start"]
|
31 | 56 |
|
0 commit comments