Docker support #6 #17
Changes from 2 commits
e8012f4
e1cc251
b328787
ac28988
54397a7
595cab2
3565fd5
1c70d74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
*.iml | ||
.git | ||
build | ||
cloud |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM gradle:4.1-jdk8 | ||
|
||
ENV HOME /home/gradle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is supposed to be a root directory for our application I would use something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjusted |
||
|
||
RUN mkdir -p $HOME/app \ | ||
&& cd $HOME/app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same is achieved with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, fixed |
||
|
||
WORKDIR $HOME/app | ||
|
||
USER root | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docker engine runs containers as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'gradle' image creates own 'gradle' user and sets it as current user. Therefore switch back to 'root' to do all pre-cooking is required. |
||
|
||
COPY settings.gradle . | ||
COPY api ./api | ||
|
||
RUN chown -R gradle $HOME/app | ||
|
||
USER gradle | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["gradle", "bootRun"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjusted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM gradle:4.1-jdk8 | ||
|
||
ENV HOME /home/gradle | ||
|
||
RUN mkdir -p $HOME/app \ | ||
&& cd $HOME/app | ||
WORKDIR $HOME/app | ||
|
||
COPY .env . | ||
COPY settings.gradle . | ||
|
||
CMD ["gradle", "bootRun"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using ENTRYPOINT instead of CMD to use the same Dockerfile for dev and test, see https://github.com/ctco-dev/nodejs-graphql-template/blob/issue-11-docker/Dockerfile.dev There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, adjusted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM gradle:4.1-jdk8 | ||
|
||
ENV HOME /home/gradle | ||
|
||
RUN mkdir -p $HOME/app \ | ||
&& cd $HOME/app | ||
WORKDIR $HOME/app | ||
|
||
COPY .env . | ||
COPY settings.gradle . | ||
|
||
CMD ["gradle", "clean", "test"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ buildscript { | |
ext { | ||
springBootVersion = '1.5.4.RELEASE' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
@@ -15,7 +15,7 @@ buildscript { | |
repositories { | ||
mavenCentral() | ||
} | ||
|
||
apply plugin: 'java' | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
@@ -26,6 +26,7 @@ apply from: 'dotenv.gradle' | |
|
||
bootRun() { | ||
environment << dotenv | ||
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we extract this to Dockerfile or docker-compose ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, there is a option to run the application using gradle from CLI and attach remote debugger from IDE. |
||
} | ||
|
||
dependencies { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "3" | ||
services: | ||
spring-boot-graphql-template-test: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test | ||
volumes: | ||
- $HOME/.gradle/caches:/home/gradle/.gradle/caches | ||
- ${PWD}/api:/home/gradle/app/api |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "3" | ||
services: | ||
spring-boot-graphql-template: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.dev | ||
volumes: | ||
- $HOME/.gradle/caches:/home/gradle/.gradle/caches | ||
- ${PWD}/api:/home/gradle/app/api | ||
ports: | ||
- "8080:8080" | ||
- "5005:5005" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
gradle:4.1-jdk8-alpine
instead ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can. Adjusted.