Deploy HTTP Functions with .zip archive

Package Specification

HTTP functions are packaged into zip archives.

Note

The maximum size of a zip to be uploaded using console is 40MB, for larger files store zip in OBS

Example zip Package

Example zip package structure
zip.jar
├─ lib                    # folder contains all third party jars
|  ├─ thirdparty1.jar
|  ├─ thirdparty2.jar
|  └─ ...
|
├─ bootstrap              # bootstrapfile
└─ functiongraph.jar      # jar with functiongraph code

Building a deployment package

Deployment packages can be built using maven.

Following snippets show how to build zip archive using maven:

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.5.0</version>
    <relativePath />
  </parent>

  <groupId>io.github.opentelekomcloud</groupId>
  <artifactId>opentelekomcloud-functiongraph-java-samples-doc-springboot-3x</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <description>Demo project for Spring Boot 3.x</description>
  <url>https://docs.otc.t-systems.com/opentelekomcloud-functiongraph-java</url>

  <scm>
    <connection>scm:git:git://github.com/opentelekomcloud/opentelekomcloud-functiongraph-java.git</connection>
    <developerConnection>scm:git:ssh://github.com:opentelekomcloud/opentelekomcloud-functiongraph-java.git</developerConnection>
    <url>http://github.com/opentelekomcloud/opentelekomcloud-functiongraph-java/tree/main</url>
  </scm>

  <properties>
    <java.version>17</java.version>
    <start-class>com.opentelekomcloud.samples.springboot.RestServiceApplication</start-class>
    <maven.compiler.release>17</maven.compiler.release>
  </properties>

  <dependencies>


    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
      <version>3.5.0</version>
    </dependency>


    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.0.2</version>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly/zip.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

</project>

Assembly plugin configuration

The following assembly configuration used in the maven-assemply-plugin will create a zip file as described above.

src/main/assembly/zip.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>zip</id>
  <includeBaseDirectory>true</includeBaseDirectory>

  <formats>
    <format>zip</format>
  </formats>
  <baseDirectory>/</baseDirectory>
  
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <filtered>true</filtered>
      <includes>
        <include>bootstrap</include>
      </includes>
    </fileSet>
  </fileSets>
  <files>
    <file>
      <source>${project.build.directory}/${project.artifactId}-${project.version}.jar.original</source>
      <destName>${project.artifactId}.jar</destName>
      <outputDirectory>/</outputDirectory>
    </file>
    
  </files>

  <dependencySets>
    <dependencySet>
      <outputDirectory>lib</outputDirectory>
      <excludes>
        <exclude>${project.groupId}:${project.artifactId}:jar:*</exclude>
      </excludes>
    </dependencySet>
  </dependencySets>
</assembly>

Generated zip archive

Generated zip file can be found in folder ${PROJECT_ROOT}/target/functiongraph-samples-doc-springboot-2x-0.0.1-SNAPSHOT.zip

See full code in doc-sample-springboot-3.x-rest

Deployment with the FunctionGraph console

See: Creating an HTTP Function