Skip to content

Commit

Permalink
添加standalone的profile
Browse files Browse the repository at this point in the history
  • Loading branch information
yangziwen committed Jul 17, 2021
1 parent baeb500 commit c2815a0
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 36 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,31 @@
* 运行于docker环境时,仅支持被动模式

#### 打包 & 运行
* 内嵌在程序中运行
1. 引入依赖
```xml
<dependency>
<groupId>io.github.yangziwen</groupId>
<artifactId>zy-ftp</artifactId>
<version>0.0.2</version>
</dependency>
```
2. 编写代码
```java
FtpRunner runner = FtpRunner.builder()
.localIp("127.0.0.1")
.localPort(8121)
.configFile(new File("conf/server.config"))
.logFile(new File("log/zy-ftp.log"))
.build();

runner.run();
```
* 基于jar包运行
1. 打包代码:`mvn package` or `gradle build`
1. 打包代码:`mvn package -Pstandalone` or `gradle build`
2. 启动服务:`java -jar zy-ftp.jar -c ${config_file_path}`
* 基于docker运行
1. 制作镜像:`mvn package dockerfile:build` or `gradle dockerBuild`
1. 制作镜像:`mvn package dockerfile:build -Pstandalone` or `gradle dockerBuild`
2. 启动容器:
```
docker run -d \
Expand All @@ -23,7 +43,7 @@
-p 8121:8121 \
-e PASSIVE_PORTS=40000-40060 \
-p 40000-40060:40000-40060 \
zy-ftp:0.0.1
zy-ftp:0.0.2
```
* 查看启动参数:`java -jar zy-ftp.jar -h`
* 可通过设置系统变量进行连接泄露检测,如`-Dio.netty.leakDetectionLevel=ADVANCED`
219 changes: 186 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,196 @@

<name>zy-ftp</name>
<url>http://maven.apache.org</url>
<description>A ftp server based on netty</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<distributionManagement>
<repository>
<id>repository</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<profiles>
<profile>
<id>disable-javadoc-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>${javadoc.opts}</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>standalone</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<finalName>zy-ftp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>io.github.yangziwen.zyftp.run.FtpRunner</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<repository>${project.name}</repository>
<tag>${project.version}</tag>
<skipPush>true</skipPush>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/yangziwen/zy-ftp</url>
<connection>https://github.com/yangziwen/zy-ftp</connection>
<developerConnection>https://github.com/yangziwen/zy-ftp</developerConnection>
</scm>
<developers>
<developer>
<name>yangziwen</name>
<email>[email protected]</email>
<url>https://yangziwen.github.io</url>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -104,39 +289,7 @@
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>io.github.yangziwen.zyftp.run.FtpRunner</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<repository>${project.name}</repository>
<tag>${project.version}</tag>
<skipPush>true</skipPush>
</configuration>
</plugin>
</plugins>
</build>

</project>

0 comments on commit c2815a0

Please sign in to comment.