Dockerfile构建服务

1.构建jdk1.8镜像

FROM ubuntu
MAINTAINER rolin
RUN mkdir /usr/local/jdk
WORKDIR /usr/local/jdk
ADD jdk-8u231-linux-x64.tar.gz /usr/local/jdk
ENV JAVA_HOME /usr/local/jdk/jdk1.8.0_231
ENV JRE_HOME /usr/local/jdk/jdk1.8.0_231/jre
ENV PATH $JAVA_HOME/bin:$PATH
docker build -t jdk1.8 .

2.构建Eureka镜像

2.1 修改pom.xml并打包

<build>
    <finalName>app</finalName>
    <plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
cd sm1234_eureka
mvn clean package
FROM jdk1.8
ADD app.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
docker run -di -p 7000:7000 eureka
docker logs -f --tail=20 59297ccf6b55

3.构建文章微服务

3.1修改pom.xml

<build>
    <finalName>app</finalName>
    <plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
cd sm1234_article
mvn clean package
ROM jdk1.8
ADD app.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
docker build -t article .
docker run -di --name=article -p 9001:9001 article 
docker logs -f --tail=20 59297ccf6b55

4.构建zuul微服务

4.1修改pom.xml

<build>
    <finalName>app</finalName>
    <plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
cd sm1234_zuul
mvn clean package
ROM jdk1.8
ADD app.jar /app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
docker build -t zuul .
docker run -di --name=article -p 8888:8888 zuul 
docker logs -f --tail=20 59297ccf6b55