Spring Boot and RESTful API(11)Deployment and Docker

本文介绍了一个基于SpringBoot的应用如何进行部署并使用Docker进行容器化的过程。包括了从Eclipse导入项目、清理版本控制系统信息到构建Docker镜像及运行的详细步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Spring Boot and RESTful API(11)Deployment and Docker

Find Market Place and search for buildship, Install plugin for Gradle

The import the project into Eclipse from Import Gradle Project

Clean the svn or git information
>find . -name ".svn" | xargs rm -Rf
>find . -name ".git" | xargs rm -Rf

On CentOS
here is the start file start.sh
#!/bin/sh -ex

APPLICATION_SECRET="nosessionshere"

cd /share/

java \
-Xms2G -Xmx2G -XX:MaxMetaspaceSize=256M \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-jar -Dspring.profiles.active=prod price-monitor-server.jar 2>&1

Here is the Makefile to build the image
IMAGE=sillycat/public
TAG=centos7-price-monitor-server
NAME=centos7-price-monitor-server

app-build:
./gradlew clean build -x test

docker-context:

build: docker-context
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 8080:8080 --name $(NAME) $(IMAGE):$(TAG)
debug:
docker run -ti -p 8080:8080 --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop $(NAME)
docker rm $(NAME)

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}


Here is the steps and features in Dockerfile
#Run a Simple REST API based on playframework

#Prepre the OS
FROM centos:7
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive

#Prepare S3 command tool
RUNyum --enablerepo=extras -y install epel-release
RUNyum -y update
RUNyum -y install python-pip
RUNpip install --upgrade pip
ENV PATH="~/.local/bin:${PATH}"

#Install Java
RUN yum install -y java-1.8.0-openjdk

#Install the Application
RUN mkdir /share/
WORKDIR /share/

ADD build/libs/price-monitor-server.jar /share/

#Start the Application
EXPOSE 8080
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app
CMD[ "./start.sh" ]

On RaspberryPi


References:
http://www.vogella.com/tutorials/EclipseGradle/article.html#eclipse-gradle-support
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值