One‑Click Remote Deployment of Spring Boot with IDEA and Docker
This guide walks you through setting up IntelliJ IDEA and Docker to replace manual jar uploads with a single‑click remote deployment for Spring Boot applications, covering prerequisites, SSH configuration, Docker daemon basics, Dockerfile creation, and the final one‑step deployment process.
Introduction
The article explains how to use IntelliJ IDEA together with Docker to achieve one‑click remote deployment of a Spring Boot project, comparing the traditional jar‑upload method with the automated approach.
Prerequisites
Install Docker on the target server and be familiar with writing a simple Dockerfile (or let an AI generate it).
Install IntelliJ IDEA on the local machine.
Have a runnable Spring Boot project packaged as a jar (the tutorial uses a minimal demo).
Jar Deployment vs. Remote One‑Click Deployment
Traditional jar deployment requires installing Java on the server, uploading the jar, and running java -jar each time, which involves stopping the service, re‑uploading, and restarting—an inconvenient workflow.
The IDEA+Docker method automates these steps: after initial configuration, a single click on the green run icon rebuilds the image, pushes it to the server, and starts the container, also providing real‑time log access.
Configuring Remote Deployment
1) SSH Configuration
Configure SSH in IDEA (File → Settings → Search "ssh"). Using a key‑pair authentication is recommended to avoid password prompts.
2) Docker Daemon Connection
Set up Docker daemon access in IDEA (File → Settings → Search "docker"). The Docker daemon runs on the host and manages container lifecycle, images, networking, and storage.
3) Writing the Dockerfile
# Base image
FROM openjdk:17
# Copy the built jar into the image (place the jar next to the Dockerfile)
ADD target/demo-0.0.1-SNAPSHOT.jar app.jar
# Define the container entry point
ENTRYPOINT ["java","-jar","/app.jar","--spring.profiles.active=prod"]
# Expose the application port
EXPOSE 80804) Remote Deployment Settings in IDEA
Create a new Docker deployment configuration.
Enter the SSH connection details and select the Docker daemon.
Specify the Dockerfile path and build context.
Set the run command to start the container.
After saving the configuration, clicking the green run triangle triggers the build, push, and container start in a single step.
Result
The application is deployed automatically, logs are viewable in real time within IDEA, and the web endpoint responds as expected. Although the initial setup is a bit involved, subsequent deployments become extremely fast and convenient.
Java Architect Handbook
Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
