dockerfile
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 7m24s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 7m24s
This commit is contained in:
parent
8f0bbe4e0b
commit
4b9ef4691e
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
target
|
||||||
|
.env
|
||||||
|
.data
|
||||||
|
compose.yaml
|
||||||
|
README.md
|
||||||
|
LICENSE
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
target/
|
target/
|
||||||
.env
|
.env
|
||||||
|
.data/
|
||||||
|
|||||||
43
Dockerfile
43
Dockerfile
@ -1,45 +1,22 @@
|
|||||||
# ---- STAGE 1: Build ----
|
FROM rust:1.88-bookworm AS builder
|
||||||
# Use an OpenJDK image that matches the version you develop with.
|
|
||||||
# It contains the JDK, but not Maven.
|
|
||||||
FROM eclipse-temurin:25-jdk-jammy AS builder
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# ---- Caching Dependencies ----
|
COPY Cargo.toml Cargo.lock ./
|
||||||
# First, copy the files that define the build, including the Maven Wrapper
|
|
||||||
COPY mvnw .
|
|
||||||
COPY .mvn .mvn
|
|
||||||
COPY pom.xml .
|
|
||||||
|
|
||||||
# Make the wrapper executable
|
|
||||||
RUN chmod +x ./mvnw
|
|
||||||
|
|
||||||
# Run a Maven command to download dependencies.
|
|
||||||
# Since pom.xml and wrapper files rarely change, this layer will be cached by Docker,
|
|
||||||
# speeding up subsequent builds significantly.
|
|
||||||
RUN ./mvnw dependency:go-offline
|
|
||||||
|
|
||||||
# ---- Building the Application ----
|
|
||||||
# Now, copy the source code. If only source code changes, the layers above are cached.
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
|
|
||||||
# Build the application JAR using the Maven Wrapper
|
RUN cargo build --release
|
||||||
RUN ./mvnw clean package -DskipTests
|
|
||||||
|
|
||||||
|
FROM debian:bookworm-slim AS runtime
|
||||||
|
|
||||||
# ---- STAGE 2: Runtime ----
|
|
||||||
# Use a lean Eclipse Temurin JRE image for a small and secure final container.
|
|
||||||
FROM eclipse-temurin:25-jre-jammy
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy only the built JAR file from the 'builder' stage
|
RUN apt-get update \
|
||||||
COPY --from=builder /app/target/*.jar app.jar
|
&& apt-get install -y --no-install-recommends ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=builder /app/target/release/rhythm_backend /app/rhythm_backend
|
||||||
|
|
||||||
# Expose the application port
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Command to run the application
|
ENTRYPOINT ["/app/rhythm_backend"]
|
||||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
|
||||||
|
|||||||
36
compose.prod.yaml
Normal file
36
compose.prod.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
api-prod:
|
||||||
|
image: git.kanopo.dev/rhythm/rhythm-backend:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: rhythm-api-prod
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
environment:
|
||||||
|
DB_HOST: db-prod
|
||||||
|
env_file:
|
||||||
|
- ".env"
|
||||||
|
depends_on:
|
||||||
|
db-prod:
|
||||||
|
condition: service_healthy
|
||||||
|
profiles:
|
||||||
|
- prod
|
||||||
|
|
||||||
|
db-prod:
|
||||||
|
image: postgres:18.0-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: rhythm-db-prod
|
||||||
|
ports:
|
||||||
|
- "${DB_PORT_PROD:-5433}:5432"
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${DB_USERNAME}
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
POSTGRES_DB: ${DB_NAME}
|
||||||
|
volumes:
|
||||||
|
- ./.data/postgres-prod:/var/lib/postgresql/data
|
||||||
|
profiles:
|
||||||
|
- prod
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_NAME}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 10
|
||||||
71
compose.yaml
71
compose.yaml
@ -1,39 +1,39 @@
|
|||||||
services:
|
services:
|
||||||
# api-prod:
|
api-prod:
|
||||||
# build: .
|
build: .
|
||||||
# restart: unless-stopped
|
restart: unless-stopped
|
||||||
# container_name: qrcode-api
|
container_name: rhythm-api-prod
|
||||||
# ports:
|
ports:
|
||||||
# - "8080:8080"
|
- "8080:8080"
|
||||||
# environment:
|
environment:
|
||||||
# DB_HOST: db-prod
|
DB_HOST: db-prod
|
||||||
# env_file:
|
env_file:
|
||||||
# - ".env"
|
- ".env"
|
||||||
# depends_on:
|
depends_on:
|
||||||
# db-prod:
|
db-prod:
|
||||||
# condition: service_healthy
|
condition: service_healthy
|
||||||
# profiles:
|
profiles:
|
||||||
# - prod
|
- prod
|
||||||
#
|
|
||||||
# db-prod:
|
db-prod:
|
||||||
# image: postgres:18.0-alpine
|
image: postgres:18.0-alpine
|
||||||
# restart: unless-stopped
|
restart: unless-stopped
|
||||||
# container_name: qrcode-database-prod
|
container_name: rhythm-db-prod
|
||||||
# ports:
|
ports:
|
||||||
# - "${DB_PORT:-5432}:5432"
|
- "${DB_PORT_PROD:-5433}:5432"
|
||||||
# environment:
|
environment:
|
||||||
# POSTGRES_USER: ${DB_USERNAME}
|
POSTGRES_USER: ${DB_USERNAME}
|
||||||
# POSTGRES_PASSWORD: ${DB_PASSWORD}
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
# POSTGRES_DB: ${DB_NAME}
|
POSTGRES_DB: ${DB_NAME}
|
||||||
# volumes:
|
volumes:
|
||||||
# - postgres_data:/var/lib/postgresql/data
|
- ./.data/postgres-prod:/var/lib/postgresql/data
|
||||||
# profiles:
|
profiles:
|
||||||
# - prod
|
- prod
|
||||||
# healthcheck:
|
healthcheck:
|
||||||
# test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_NAME}"]
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_NAME}"]
|
||||||
# interval: 5s
|
interval: 5s
|
||||||
# timeout: 3s
|
timeout: 3s
|
||||||
# retries: 10
|
retries: 10
|
||||||
|
|
||||||
db-dev:
|
db-dev:
|
||||||
image: postgres:18.0-alpine
|
image: postgres:18.0-alpine
|
||||||
@ -55,4 +55,3 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user