Skip to content

Commit cd75c5a

Browse files
committed
Docker image
1 parent f346c59 commit cd75c5a

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*
2+
!gradle
3+
!src
4+
!build.gradle
5+
!gradlew
6+
!gradlew.bat
7+
!lombok.config
8+
!settings.gradle

.github/workflows/package.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Create and publish Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions:checkout@v2
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v1
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v1
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v3
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
- name: Build and push
38+
uses: docker/build-push-action@v2
39+
with:
40+
context: .
41+
push: true
42+
tags: ${{ steps.meta.outputs.tags }}
43+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM openjdk:12-ea-jdk-alpine AS build
2+
3+
RUN apk add --no-cache wget unzip
4+
5+
WORKDIR /opt
6+
7+
RUN wget -O gradle.zip "https://services.gradle.org/distributions/gradle-5.2-all.zip" \
8+
&& unzip -d ./gradle ./gradle.zip \
9+
&& rm ./gradle.zip
10+
ENV PATH=$PATH:/opt/gradle/gradle-5.2/bin
11+
12+
WORKDIR /lexidb
13+
14+
COPY src /lexidb/src/
15+
COPY gradle /lexidb/gradle/
16+
COPY build.gradle /lexidb/
17+
COPY gradlew /lexidb/
18+
COPY gradlew.bat /lexidb/
19+
COPY lombok.config /lexidb/
20+
COPY settings.gradle /lexidb/
21+
22+
RUN gradle build
23+
24+
25+
26+
FROM openjdk:16-alpine
27+
28+
RUN addgroup --system java_user && adduser -S -s /bin/false -G java_user java_user
29+
RUN mkdir /lexidb \
30+
&& chown -R java_user:java_user /lexidb
31+
32+
COPY --from=build --chown=java_user:java_user /lexidb/build/libs/lexidb-2.0.jar /lexidb/
33+
COPY --from=build --chown=java_user:java_user /lexidb/src/main/resources/app.properties /lexidb/
34+
35+
WORKDIR /lexidb
36+
37+
EXPOSE 1189
38+
USER java_user
39+
40+
ENTRYPOINT ["java", "-jar", "lexidb-2.0.jar"]
41+
CMD ["./app.properties"]
42+

make_docker.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
DOCKER_BUILDKIT=1 docker build --progress=plain -f Dockerfile -t lexidb:0.0.1 .

readme.md

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ Build using the following command in the project directroy;
1313
$ gradle build
1414
```
1515

16+
## Running on Docker
17+
18+
There is a docker instance of LexiDB which can be ran using the following command:
19+
20+
``` bash
21+
docker run -it -p 127.0.0.1:3000:1189 --rm ucrel/lexidb:0.0.1
22+
```
23+
1624
## Deploy
1725

1826
Deploy locally;
@@ -21,6 +29,19 @@ Deploy locally;
2129
$ java -jar build/libs/lexidb-2.0.jar /path/to/app.properties
2230
```
2331

32+
```
33+
docker run -it -p 127.0.0.1:3000:1189 --rm lexidb:0.0.1
34+
```
35+
36+
```
37+
docker run -it -p 127.0.0.1:3000:1189 --init --entrypoint "java" --rm lexidb:0.0.1 -Xmx8g -jar lexidb-2.0.jar ./app.properties
38+
```
39+
40+
```
41+
docker run -it -p 127.0.0.1:3000:1189 --init --entrypoint "java" --memory=8g --memory-swap=8g --rm lexidb:0.0.1 -Xmx8g -jar lexidb-2.0.jar ./app.properties
42+
```
43+
44+
2445
## Test
2546

2647
You can test whether the server is running by making a simple API call in your browser; [http://localhost:1189/api/test](http://localhost:1189/api/test)

0 commit comments

Comments
 (0)