From cdddbc4d4f9770c413691effda60dd77e4fa4d76 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Fri, 10 Apr 2026 17:34:53 +0700 Subject: [PATCH] feat: add Docker Compose setup for server and web client --- .dockerignore | 13 +++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ landlords-server/Dockerfile | 28 ++++++++++++++++++++++++++++ web-client/Dockerfile | 17 +++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 .dockerignore create mode 100644 docker-compose.yml create mode 100644 landlords-server/Dockerfile create mode 100644 web-client/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dc0b021 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +**/target +**/node_modules +**/dist +.git +.github +.claude +.idea +.vscode +docs +plans +*.md +demo.gif +repomix-output.xml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4c80465 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +services: + server: + build: + context: . + dockerfile: landlords-server/Dockerfile + container_name: caro-server + ports: + - "1024:1024" # TCP / Protobuf (CLI client) + - "1025:1025" # WebSocket + static HTTP (web client) + restart: unless-stopped + + web-client: + build: + context: ./web-client + dockerfile: Dockerfile + container_name: caro-web-client + ports: + - "8080:80" + depends_on: + - server + restart: unless-stopped diff --git a/landlords-server/Dockerfile b/landlords-server/Dockerfile new file mode 100644 index 0000000..96d8cd3 --- /dev/null +++ b/landlords-server/Dockerfile @@ -0,0 +1,28 @@ +# Build stage: compile server jar with Maven +FROM maven:3.9-eclipse-temurin-21 AS build +WORKDIR /build + +# Copy parent pom and all module poms first for dependency caching +COPY pom.xml . +COPY landlords-common/pom.xml landlords-common/ +COPY landlords-server/pom.xml landlords-server/ +COPY landlords-client/pom.xml landlords-client/ + +# Copy sources (common + server only — client not needed for runtime) +COPY landlords-common/src landlords-common/src +COPY landlords-server/src landlords-server/src +COPY landlords-client/src landlords-client/src +COPY protoc-resource protoc-resource + +RUN mvn -B -pl landlords-server -am clean package -DskipTests + +# Runtime stage +FROM eclipse-temurin:21-jre-alpine +WORKDIR /app + +COPY --from=build /build/landlords-server/target/landlords-server-1.4.0.jar app.jar + +# TCP (protobuf) and WebSocket (WS + static HTTP) ports +EXPOSE 1024 1025 + +ENTRYPOINT ["java", "-jar", "app.jar", "-p", "1024"] diff --git a/web-client/Dockerfile b/web-client/Dockerfile new file mode 100644 index 0000000..9cf0c8f --- /dev/null +++ b/web-client/Dockerfile @@ -0,0 +1,17 @@ +# Build stage: Vite production build +FROM node:22-alpine AS build +WORKDIR /build + +COPY package.json package-lock.json ./ +RUN npm ci + +COPY index.html vite.config.js ./ +COPY public public +COPY src src +RUN npm run build + +# Runtime stage: nginx serves static assets +FROM nginx:alpine +COPY --from=build /build/dist /usr/share/nginx/html + +EXPOSE 80