Prerequisites
Make sure Docker and Docker Compose are installed on your machine. Refer to the Docker documentation for installtaion instructions if needed.
Building the Docker Image
Go to the root directory of the RuoYi project and create a file named Dockerfile with the following content:
FROM eclipse-temurin:8-jre-alpine
COPY target/*.jar service.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "service.jar"]
Then build the image by running:
docker build -t ruoyi-service .
Orchestrating with Docker Compose
Create a docker-compose.yml file to define and run the service:
version: '3.8'
services:
app:
image: ruoyi-service
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=prod
volumes:
- ./logs:/app/logs
restart: unless-stopped
Launch the service with:
docker-compose up -d
The application will be accessibel at http://localhost:8080 once the container starts.