-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fc7c6c
commit 26b932f
Showing
5 changed files
with
212 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
tools: replikativ/clj-tools@0 | ||
|
||
jobs: | ||
build: | ||
executor: tools/clojurecli | ||
steps: | ||
- attach_workspace: | ||
at: /home/circleci | ||
- run: | ||
name: Build | ||
command: clojure -Sthreads 1 -T:build uber | ||
no_output_timeout: 5m | ||
- persist_to_workspace: | ||
root: /home/circleci/ | ||
paths: | ||
- replikativ/target | ||
deploy: | ||
executor: tools/clojurecli | ||
steps: | ||
- attach_workspace: | ||
at: /home/circleci | ||
- run: | ||
name: Deploy to Docker Hub | ||
command: | | ||
clojure -Sthreads 1 \ | ||
-T:build deploy-image \ | ||
:docker-login ${DOCKER_LOGIN} \ | ||
:docker-password ${DOCKER_PASSWORD} \ | ||
no_output_timeout: 5m | ||
release: | ||
executor: tools/clojurecli | ||
steps: | ||
- attach_workspace: | ||
at: /home/circleci | ||
- run: | ||
name: Release | ||
command: clojure -Sthreads 1 -T:build release | ||
|
||
workflows: | ||
build-and-deploy: | ||
jobs: | ||
- tools/setup: | ||
context: dockerhub-deploy | ||
setup_cljs: false | ||
- tools/format: | ||
context: dockerhub-deploy | ||
requires: | ||
- tools/setup | ||
- build: | ||
context: dockerhub-deploy | ||
requires: | ||
- tools/setup | ||
- deploy: | ||
context: | ||
- dockerhub-deploy | ||
filters: | ||
branches: | ||
only: main | ||
requires: | ||
- tools/setup | ||
- tools/format | ||
- build | ||
- release: | ||
context: | ||
- dockerhub-deploy | ||
- github-token | ||
filters: | ||
branches: | ||
only: main | ||
requires: | ||
- deploy |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.clj-kondo/ | ||
.cpcache/ | ||
target/ |
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,7 @@ | ||
FROM gcr.io/distroless/java17-debian11 | ||
|
||
COPY target/datahike-server-*-standalone.jar / | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["/datahike-server-standalone.jar"] |
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,109 @@ | ||
(ns build | ||
(:require | ||
[borkdude.gh-release-artifact :as gh] | ||
[clojure.tools.build.api :as b] | ||
[deps-deploy.deps-deploy :as dd]) | ||
(:import | ||
[java.nio.file Paths] | ||
[com.google.cloud.tools.jib.api Jib Containerizer RegistryImage TarImage] | ||
[com.google.cloud.tools.jib.api.buildplan AbsoluteUnixPath Port])) | ||
|
||
(def lib 'io.replikativ/souffleuse) | ||
(def version (format "0.1.%s" (b/git-count-revs nil))) | ||
(def current-commit (gh/current-commit)) | ||
(def class-dir "target/classes") | ||
(def basis (b/create-basis {:project "deps.edn"})) | ||
(def jar-path (format "target/%s-%s.jar" (name lib) version)) | ||
(def uber-file (format "%s-%s-standalone.jar" (name lib) version)) | ||
(def uber-path (format "target/%s" uber-file)) | ||
(def image (format "docker.io/replikativ/souffleuse:%s" version)) | ||
|
||
(defn get-version | ||
[_] | ||
(println version)) | ||
|
||
(defn clean | ||
[_] | ||
(b/delete {:path "target"})) | ||
|
||
(defn jar | ||
[_] | ||
(b/write-pom {:class-dir class-dir | ||
:src-pom "./template/pom.xml" | ||
:lib lib | ||
:version version | ||
:basis basis | ||
:src-dirs ["src"]}) | ||
(b/copy-dir {:src-dirs ["src" "resources"] | ||
:target-dir class-dir}) | ||
(b/jar {:class-dir class-dir | ||
:jar-file jar-path})) | ||
|
||
(defn uber | ||
[_] | ||
(clean nil) | ||
(b/copy-dir {:src-dirs ["src" "resources"] | ||
:target-dir class-dir}) | ||
(b/compile-clj {:basis basis | ||
:src-dirs ["src"] | ||
:class-dir class-dir}) | ||
(b/uber {:class-dir class-dir | ||
:uber-file uber-path | ||
:basis basis | ||
:main 'souffleuse.core})) | ||
|
||
(defn deploy | ||
"Don't forget to set CLOJARS_USERNAME and CLOJARS_PASSWORD env vars." | ||
[_] | ||
(dd/deploy {:installer :remote :artifact jar-path | ||
:pom-file (b/pom-path {:lib lib :class-dir class-dir})})) | ||
|
||
(defn release | ||
[_] | ||
(-> (gh/overwrite-asset {:org "replikativ" | ||
:repo (name lib) | ||
:tag version | ||
:commit current-commit | ||
:file uber-path | ||
:content-type "application/java-archive"}) | ||
:url | ||
println)) | ||
|
||
(defn install | ||
[_] | ||
(clean nil) | ||
(jar nil) | ||
(b/install {:basis (b/create-basis {}) | ||
:lib lib | ||
:version version | ||
:jar-file jar-path | ||
:class-dir class-dir})) | ||
|
||
(defn deploy-image | ||
[{:keys [docker-login docker-password]}] | ||
(if-not (and docker-login docker-password) | ||
(println "Docker credentials missing.") | ||
(.containerize | ||
(-> (Jib/from "gcr.io/distroless/java17-debian11") | ||
(.addLayer [(Paths/get uber-path (into-array String[]))] (AbsoluteUnixPath/get "/")) | ||
(.setProgramArguments [(format "/%s" uber-file)]) | ||
(.addExposedPort (Port/tcp 3000))) | ||
(Containerizer/to | ||
(-> (RegistryImage/named image) | ||
(.addCredential (str docker-login) (str docker-password)))))) | ||
(println "Deployed new image to Docker Hub: " image)) | ||
|
||
(comment | ||
(def docker-login "") | ||
(def docker-password "") | ||
|
||
(b/pom-path {:lib lib :class-dir class-dir}) | ||
(clean nil) | ||
(compile nil) | ||
(jar nil) | ||
(uber nil) | ||
(deploy-image {:docker-login docker-login | ||
:docker-password docker-password}) | ||
(deploy nil) | ||
(release nil) | ||
(install nil)) |
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,21 @@ | ||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.replikativ</groupId> | ||
<artifactId>souffleuse</artifactId> | ||
<packaging>jar</packaging> | ||
<name>souffleuse</name> | ||
<description>A simple bot to announce releases and meetings to Slack and Twitter</description> | ||
<url>https://datahike.io</url> | ||
<licenses> | ||
<license> | ||
<name>Eclipse</name> | ||
<url>http://www.eclipse.org/legal/epl-v10.html</url> | ||
</license> | ||
</licenses> | ||
<scm> | ||
<connection>scm:git:git@github.com:replikativ/souffleuse.git</connection> | ||
<developerConnection>scm:git:git@github.com/replikativ/souffleuse.git</developerConnection> | ||
<url>https://github.com/replikativ/souffleuse</url> | ||
</scm> | ||
</project> |