Skip to content

Instantly share code, notes, and snippets.

@trautonen
Last active March 15, 2021 15:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trautonen/eff9b4066077053282dc to your computer and use it in GitHub Desktop.
Save trautonen/eff9b4066077053282dc to your computer and use it in GitHub Desktop.
New year's Spring Boot tricks in a container
$ mvn clean package docker:build
gofurldev:
build: .
dockerfile: Dockerfile.dev
links:
- gofurlmongo
ports:
- "8080:8080"
volumes:
- .:/gofurl
- ~/.m2:/root/.m2
gofurl:
image: gofore/gofurl
links:
- gofurlmongo
ports:
- "8080:8080"
gofurlmongo:
image: mongo:3.1
ports:
- "27017:27017"
volumes_from:
- gofurldata
gofurldata:
image: debian:wheezy
volumes:
- /data/db
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.3.8</version>
<configuration>
<imageName>gofore/gofurl</imageName>
<dockerDirectory>docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
$ docker-compose up gofurldev
$ docker-compose up gofurl
FROM java:8
RUN mkdir /opt/maven
RUN curl -s -j -k -L "http://www.eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" | tar xz --strip=1 -C "/opt/maven"
ENV PATH /opt/maven/bin:$PATH
WORKDIR /gofurl
CMD ["mvn", "-Dfork=true", "-Drun.jvmArguments=-Dspring.data.mongodb.uri=mongodb://gofurlmongo:27017/gofurl", "spring-boot:run"]
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment