Cloud Native 6 min read

Step‑by‑Step Dockerfile Deployment for a SpringBoot + Vue Split‑Stack Application

This guide walks through deploying a SpringBoot‑Vue split‑stack project with Docker by creating separate containers for Redis and MySQL, building custom Docker images for the backend JAR and the Nginx‑served frontend, configuring host networking, and exposing the necessary ports for verification.

The Dominant Programmer
The Dominant Programmer
The Dominant Programmer
Step‑by‑Step Dockerfile Deployment for a SpringBoot + Vue Split‑Stack Application

The article begins by referencing a previous tutorial that sets up a SpringBoot + Vue split‑stack project locally, then explains how to deploy it using Docker.

1. Deploy Redis in Docker – Use a Docker container for Redis with the password 123456, which must match the password configured in the SpringBoot application.

2. Deploy MySQL in Docker – Run a MySQL 5.7 container with root password 123456 and add the option --lower_case_table_names=1 to avoid case‑sensitivity issues that cause "table not found" errors. Example command:

docker run -p 3306:3306 --name mysql -v /usr/local/docker/mysql/conf:/etc/mysql -v /usr/local/docker/mysql/logs:/var/log/mysql -v /usr/local/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --lower_case_table_names=1

3. Build a custom Docker image for the backend JAR – The JAR expects Redis and MySQL at localhost, so the container must run in host network mode to reach those services. The article notes a potential FontConfiguration error when launching the JAR and links to a troubleshooting post.

Run the backend container with:

docker run -d -p 7777:7777 --net=host badaoserver

Port 7777 is the SpringBoot service port.

4. Build a custom Docker image for the frontend – Package the Vue dist directory into an Nginx image. The Nginx configuration maps the root to /usr/share/nginx/html and proxies API requests under /prod-api/ to the backend at http://localhost:7777/:

server {
    listen       100;
    server_name  localhost;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    location /prod-api/ {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:7777/;
    }
}

Port 100 is the frontend port. When launching the Nginx container, also use --net=host: docker run -d -p 100:100 --net=host badaofont 5. Open firewall ports and verify – Allow port 100 on the host:

firewall-cmd --add-port=100/tcp --permanent
firewall-cmd --reload

After starting all containers, access http://<em>host_ip</em>:100 to see the deployed application. The article includes screenshots of the running containers, Nginx logs, and a successful verification of the backend verification code endpoint.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerRedisVueMySQLNginxSpringBootDockerfile
The Dominant Programmer
Written by

The Dominant Programmer

Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.