Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
foxyseta committed Feb 27, 2021
1 parent 686aba5 commit 427bf9f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 61 deletions.
18 changes: 6 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Build stage
FROM maven:3.6.0-jdk-11-slim AS build
COPY telegrindr/src src
COPY telegrindr/pom.xml pom.xml
RUN mvn -f pom.xml clean package
FROM maven:3.6.3-openjdk-11-slim AS build
WORKDIR /app
COPY telegrindr .
RUN mvn clean package

#Package stage
FROM openjdk:11-jre-slim
VOLUME /tmp
COPY --from=build target/telegrindr-1.0-SNAPSHOT.jar telegrindr.jar
ARG JAVA_OPTS
ARG TOKEN_ID
ARG USERNAME="TelegrindrBot"
ARG CREATOR_ID
ENV JAVA_OPTS=$JAVA_OPTS TOKEN_ID=$TOKEN_ID USERNAME=$USERNAME CREATOR_ID=$CREATOR_ID
COPY --from=build /app/target/telegrindr-1.0-SNAPSHOT.jar telegrindr.jar
EXPOSE 8080
ENTRYPOINT exec java $JAVA_OPTS -jar telegrindr.jar $TOKEN_ID $USERNAME $CREATOR_ID
ENTRYPOINT java $JAVA_OPTS -jar telegrindr.jar $TOKEN_ID $USERNAME $CREATOR_ID
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@ class, you can launch it. Your environment needs to provide three arguments:
1. the bot's token
1. the bot's username
1. the bot's creator's identifier<br />
For example, you got a single executable JAR file named `telegrindr.jar` in
For example, if you got a single executable JAR file named `telegrindr.jar` in
your current directory, you can run it from Bash like this:
```bash
$ java -jar telegrindr.jar 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 telegrindrBot 1234567890
```
#### With Docker
After building the project using [`Main`](./src/Main.java#L13) as your main
class, you should have a single executable JAR file named `telegrindr.jar` in
the parent directory. You can build your image like this:
In Bash, you can build your image like this:
```bash
$ docker build . -t telegrindr
```
Then, you can run it:
```bash
$ docker build docker
-e BOT_TOKEN=$BOT_TOKEN
-e BOT_USERNAME=$BOT_USERNAME
-e BOT_CREATOR_ID=$BOT_CREATOR_ID
docker run --rm -it \
-eTOKEN_ID=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 \
-eUSERNAME=telegrindrBot \
-eCREATOR_ID=1234567890 \
telegrindr
```
88 changes: 47 additions & 41 deletions telegrindr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,59 @@
</dependencies>

<build>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<archive>
<manifest>
<mainClass>io.github.foxyseta.telegrindr.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<artifactSet>
<includes>
<include>org.telegram:*</include>
<include>org.apache.*:*</include>
<include>org.json:*</include>
<include>commons-logging:commons-logging</include>
<include>org.slf4j:*</include>
<include>org.mapdb:*</include>
<include>com.fasterxml.*:*</include>
<include>org.jetbrains.kotlin:*</include>
<include>org.eclipse.collections:*</include>
<include>net.jpountz.*:*</include>
<include>com.google.*:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

0 comments on commit 427bf9f

Please sign in to comment.