Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ jobs:
./lein uberjar
- name: Build native image
run: |
./lein native-image
# upx --lzma --best gitwerk
mv target/gitwerk gitwerk
make gitwerk-static
upx -9 gitwerk
zip --junk-paths gitwerk-linux-amd64 gitwerk
- name: Upload artifact
uses: actions/upload-artifact@v1
Expand Down Expand Up @@ -64,15 +63,15 @@ jobs:
JAVA_VERSION: java8
- name: Install dependencies
run: |
brew install leiningen
brew install leiningen upx
gu install native-image
- name: Build uberjar
run: |
lein uberjar
- name: Build native image
run: |
lein native-image
mv target/gitwerk gitwerk
make
upx -9 gitwerk
zip --junk-paths gitwerk-macos-amd64 gitwerk
- name: Upload artifact
uses: actions/upload-artifact@v1
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ COPY src src

RUN lein uberjar

COPY native-config native-config
COPY reflection.json reflection.json
COPY Makefile Makefile

RUN lein native-image
RUN make

RUN mkdir -p /out/lib \
&& cp $JAVA_HOME/jre/lib/amd64/libsunec.so /out/lib/ \
Expand All @@ -34,6 +35,6 @@ LABEL maintainer "rinx <rintaro.okamura@gmail.com>"
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

COPY --from=graalvm /out /gitwerk-libs
COPY --from=graalvm /gitwerk/target/gitwerk /gitwerk
COPY --from=graalvm /gitwerk/gitwerk /gitwerk

CMD ["/gitwerk", "-Djava.library.path=/gitwerk-libs/lib", "-Djavax.net.ssl.trustStore=/gitwerk-libs"]
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
XMS = 2g
XMX = 7g

NATIVE_IMAGE_CONFIG_OUTPUT_DIR=native-config

TARGET_JAR=target/gitwerk-0.1.0-SNAPSHOT-standalone.jar

ADDITIONAL_OPTIONS=""

.PHONY: all
all: gitwerk

.PHONY: clean
clean:
rm -f gitwerk
rm -rf target

.PHONY: profile/native-image-config
profile/native-image-config: \
$(NATIVE_IMAGE_CONFIG_OUTPUT_DIR) \
$(TARGET_JAR)
java -agentlib:native-image-agent=config-output-dir=$(NATIVE_IMAGE_CONFIG_OUTPUT_DIR) \
-jar $(TARGET_JAR) clone http://github.com/rinx/gitwerk
(cd gitwerk; \
java -agentlib:native-image-agent=config-merge-dir=../$(NATIVE_IMAGE_CONFIG_OUTPUT_DIR) \
-jar ../$(TARGET_JAR) log)
(cd gitwerk; \
java -agentlib:native-image-agent=config-merge-dir=../$(NATIVE_IMAGE_CONFIG_OUTPUT_DIR) \
-jar ../$(TARGET_JAR) tag)
rm -rf gitwerk

$(NATIVE_IMAGE_CONFIG_OUTPUT_DIR):
mkdir -p $@

lein:
curl -o lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x lein \
&& ./lein version

gitwerk: \
$(TARGET_JAR)
native-image \
-jar $(TARGET_JAR) \
-H:Name=gitwerk \
-H:+ReportExceptionStackTraces \
-H:Log=registerResource: \
-H:ReflectionConfigurationFiles=reflection.json \
--enable-url-protocols=http,https \
--enable-all-security-services \
-H:+JNI \
--verbose \
--no-fallback \
--no-server \
--report-unsupported-elements-at-runtime \
--initialize-at-run-time=org.eclipse.jgit.transport.HttpAuthMethod$$Digest \
--initialize-at-run-time=org.eclipse.jgit.lib.GpgSigner \
--initialize-at-run-time=io.quarkus.jsch.runtime.PortWatcherRunTime \
--initialize-at-build-time \
-H:IncludeResourceBundles=org.eclipse.jgit.internal.JGitText \
--allow-incomplete-classpath \
-J-Dclojure.spec.skip-macros=true \
-J-Dclojure.compiler.direct-linking=true \
-J-Xms$(XMS) \
-J-Xmx$(XMX)

.PHONY: gitwerk-static
gitwerk-static: \
$(TARGET_JAR)
native-image \
-jar $(TARGET_JAR) \
-H:Name=gitwerk \
-H:+ReportExceptionStackTraces \
-H:Log=registerResource: \
-H:ReflectionConfigurationFiles=reflection.json \
--enable-url-protocols=http,https \
--enable-all-security-services \
-H:+JNI \
--verbose \
--no-fallback \
--no-server \
--report-unsupported-elements-at-runtime \
--initialize-at-run-time=org.eclipse.jgit.transport.HttpAuthMethod$$Digest \
--initialize-at-run-time=org.eclipse.jgit.lib.GpgSigner \
--initialize-at-run-time=io.quarkus.jsch.runtime.PortWatcherRunTime \
--initialize-at-build-time \
-H:IncludeResourceBundles=org.eclipse.jgit.internal.JGitText \
--allow-incomplete-classpath \
--static \
-J-Dclojure.spec.skip-macros=true \
-J-Dclojure.compiler.direct-linking=true \
-J-Xms$(XMS) \
-J-Xmx$(XMX)

$(TARGET_JAR): lein src
./lein uberjar
6 changes: 0 additions & 6 deletions native-config/jni-config.json

This file was deleted.

2 changes: 0 additions & 2 deletions native-config/proxy-config.json

This file was deleted.

15 changes: 0 additions & 15 deletions native-config/resource-config.json

This file was deleted.

36 changes: 7 additions & 29 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,14 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.10.2-alpha1"]
[org.clojure/tools.cli "0.4.2"]
[metosin/jsonista "0.2.5"]
[camel-snake-kebab "0.4.0"]
[org.clojure/tools.cli "1.0.194"]
[cheshire "5.10.0"]
[clj-commons/clj-yaml "0.7.1"]
[io.quarkus/quarkus-jgit "1.4.1.Final"]
[borkdude/sci "0.0.13-alpha.17"]
[org.martinklepsch/clj-http-lite "0.4.3"]]
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
:native-image {:name "gitwerk"
:opts ["-H:+ReportExceptionStackTraces"
"-H:Log=registerResource:"
"-H:ConfigurationFileDirectories=native-config"
"--enable-url-protocols=http,https"
"--enable-all-security-services"
"-H:+JNI"
"--verbose"
"--no-fallback"
"--no-server"
"--report-unsupported-elements-at-runtime"
"--initialize-at-run-time=org.eclipse.jgit.transport.HttpAuthMethod$Digest"
"--initialize-at-run-time=org.eclipse.jgit.lib.GpgSigner"
"--initialize-at-run-time=io.quarkus.jsch.runtime.PortWatcherRunTime"
"--initialize-at-build-time"
"-H:IncludeResourceBundles=org.eclipse.jgit.internal.JGitText"
"--allow-incomplete-classpath"
"-J-Xms2g"
"-J-Xmx7g"]
:jvm-opts ["-Dclojure.spec.skip-macros=true"
"-Dclojure.compiler.direct-linking=true"]}
:profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"]
[orchestra "2019.02.06-1"]]
:source-paths ["dev"]}
:uberjar {:aot :all
:profiles {:uberjar {:aot :all
:global-vars {*assert* false}
:jvm-opts ["-Dclojure.spec.skip-macros=true"
"-Dclojure.compiler.direct-linking=true"]
:main gitwerk.core}})
File renamed without changes.
2 changes: 0 additions & 2 deletions src/gitwerk/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[clojure.tools.cli :as cli]
[clojure.string :as string]
[clojure.pprint :as pprint]
[clojure.edn :as edn]
[clojure.java.io :as io]
[gitwerk.service.runner :as runner])
(:gen-class))

Expand Down
16 changes: 7 additions & 9 deletions src/gitwerk/internal/json.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
(ns gitwerk.internal.json
(:require
[jsonista.core :as jsonista]
[camel-snake-kebab.core :as csk]))

(def json-mapper
(jsonista/object-mapper
{:pretty true
:decode-key-fn csk/->kebab-case-keyword}))
[cheshire.core :as cheshire]))

(defn read-value [obj]
(jsonista/read-value obj json-mapper))
(cheshire/parse-string obj true))

(defn write-json [obj]
(cheshire/generate-string obj))

(def exports
{'read-value read-value})
{'read-value read-value
'write-json write-json})
13 changes: 13 additions & 0 deletions src/gitwerk/internal/yaml.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns gitwerk.internal.yaml
(:require
[clj-yaml.core :as yaml]))

(defn read-value [obj]
(yaml/parse-string obj))

(defn write-yaml [obj]
(yaml/generate-string obj))

(def exports
{'read-value read-value
'write-yaml write-yaml})
6 changes: 4 additions & 2 deletions src/gitwerk/primitives.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
(ns gitwerk.primitives
(:require
[clojure.pprint :as pprint]))
[clojure.pprint :as pprint]
[clojure.java.shell :as shell]))

(defn getenv [e]
(System/getenv e))

(def clj-primitives
{'pprint pprint/pprint
'getenv getenv})
'getenv getenv
'sh shell/sh})
4 changes: 3 additions & 1 deletion src/gitwerk/service/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[gitwerk.internal.io :as internal.io]
[gitwerk.internal.json :as internal.json]
[gitwerk.internal.semver :as internal.semver]
[gitwerk.internal.yaml :as internal.yaml]
[gitwerk.prelude :as prelude]
[gitwerk.primitives :as primitives]))

Expand All @@ -15,7 +16,8 @@
'github internal.github/exports
'io internal.io/exports
'json internal.json/exports
'semver internal.semver/exports})
'semver internal.semver/exports
'yaml internal.yaml/exports})

(defn run
[{:keys [command args options] :as ctx}]
Expand Down