-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support run cache server in docker (#18)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
- Loading branch information
1 parent
e6fbf5d
commit 4183f01
Showing
8 changed files
with
181 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM maven:3.9.6-amazoncorretto-21 AS builder | ||
|
||
WORKDIR /workspace | ||
COPY . . | ||
RUN mvn package -DskipTests -Djavafx.platform=linux -DskipLaunch4j | ||
|
||
FROM ubuntu/jre:17-22.04_39 | ||
|
||
WORKDIR /workspace | ||
COPY --from=builder /workspace/target/listening-0.0.1-SNAPSHOT-full-linux.jar listening.jar | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["-cp", "listening.jar", "listening.linuxsuren.github.io.cli.CacheServerCLI"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/listening/linuxsuren/github/io/cli/CacheServerCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2024 LinuxSuRen. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package listening.linuxsuren.github.io.cli; | ||
|
||
import listening.linuxsuren.github.io.server.CacheServer; | ||
import org.apache.commons.cli.*; | ||
|
||
import java.io.IOException; | ||
|
||
public class CacheServerCLI { | ||
private static final int defaultPort = 8080; | ||
|
||
public static void main(String[] args) { | ||
// create the command line parser | ||
CommandLineParser parser = new DefaultParser(); | ||
|
||
// create the Options | ||
Options options = new Options(); | ||
options.addOption("p", "port", true, "The cache server port"); | ||
|
||
int port = 0; | ||
try { | ||
// parse the command line arguments | ||
CommandLine line = parser.parse(options, args); | ||
|
||
String portStr = line.getOptionValue("port", "" + defaultPort); | ||
|
||
port = Integer.parseInt(portStr); | ||
} catch (ParseException exp) { | ||
System.out.println("Unexpected exception:" + exp.getMessage()); | ||
} catch (NumberFormatException e) { | ||
port = defaultPort; | ||
System.out.println("got invalid port number:" + e.getMessage()); | ||
} | ||
|
||
try { | ||
new CacheServer().start(port); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters