Skip to content

Commit

Permalink
Add docker support for running the server inside a container
Browse files Browse the repository at this point in the history
  • Loading branch information
kartickvijayakumar committed Oct 14, 2021
1 parent d0a954c commit 7fa2991
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM openjdk:8 AS builder
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle* settings.gradle* gradle* $APP_HOME
COPY gradle $APP_HOME/gradle
RUN ./gradlew build || return 0
COPY . .
RUN ./gradlew installDist

FROM openjdk:8 AS runner
ENV APP_HOME=/usr/app/
ENV EXECUTABLE_NAME=bar-server
WORKDIR $APP_HOME
COPY --from=builder $APP_HOME/server/build/ .
EXPOSE 50051
CMD ./install/server/bin/$EXECUTABLE_NAME
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ The starter sources are organized into the following top-level folders:
./gradlew :server:BarServer
```

If you wish to start the server on a docker container (assuming you have docker installed on your machine)
```sh
docker-compose up
```

This will start the server and open up the 50051 port for connections

In another console, run the client which will make requests to the server:

```sh
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3"
services:
app:
build: .
ports:
- "50051:50051"
2 changes: 1 addition & 1 deletion stub/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
}

sourceSets {
Expand Down

0 comments on commit 7fa2991

Please sign in to comment.