Skip to content

Commit

Permalink
[fix] Actually publish verification-client (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferozco authored Oct 30, 2018
1 parent 3ddf968 commit 5a967bb
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 57 deletions.
13 changes: 11 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ jobs:
- *SAVE_REGISTRY
- persist_to_workspace:
root: .
paths: [ ./target/release/conjure-verification-server ]
paths:
- ./target/release/conjure-verification-server
- ./target/release/conjure-verification-client

publish-docker:
docker:
Expand All @@ -64,12 +66,15 @@ jobs:
- attach_workspace: { at: . } # this gets the release binary from the 'cargo-build-linux' job
- run: ./scripts/docker_build.sh
- run: docker run palantirtechnologies/conjure-verification-server:$(git describe --tags --always --first-parent) --help
- run: docker run palantirtechnologies/conjure-verification-client:$(git describe --tags --always --first-parent) --help
- deploy:
command: |
if [[ "${CIRCLE_BRANCH}" == "develop" || "${CIRCLE_TAG}" =~ [0-9]+(\.[0-9]+)+(-[a-zA-Z]+[0-9]*)* ]]; then
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
docker push palantirtechnologies/conjure-verification-server:$(git describe --tags --always --first-parent)
docker push palantirtechnologies/conjure-verification-server:latest
docker push palantirtechnologies/conjure-verification-client:$(git describe --tags --always --first-parent)
docker push palantirtechnologies/conjure-verification-client:latest
fi
cargo-build-osx:
Expand Down Expand Up @@ -103,9 +108,13 @@ jobs:
- *SAVE_REGISTRY
- persist_to_workspace:
root: .
paths: [ ./target/x86_64-apple-darwin/release/conjure-verification-server ]
paths:
- ./target/x86_64-apple-darwin/release/conjure-verification-server
- ./target/x86_64-apple-darwin/release/conjure-verification-client
- store_artifacts:
path: ./target/x86_64-apple-darwin/release/conjure-verification-server
- store_artifacts:
path: ./target/x86_64-apple-darwin/release/conjure-verification-client

publish:
docker:
Expand Down
49 changes: 27 additions & 22 deletions gradle/publish-rust-dist.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apply plugin: 'java'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

def variants = ['server', 'client']

bintray {
user = System.env.BINTRAY_USERNAME
key = System.env.BINTRAY_PASSWORD
Expand All @@ -11,7 +13,7 @@ bintray {
name = rootProject.name
userOrg = 'palantir'
licenses = ['Apache-2.0']
publications = ['distTarLinux', 'distTarOsx']
publications = variants.collectMany { ["${it}DistTarLinux", "${it}DistTarOsx"] }
}
}

Expand All @@ -20,31 +22,34 @@ bintrayUpload.onlyIf {
versionDetails().isCleanTag
}

task distTarLinux(type: Tar) {
from "target/release/conjure-verification-server"
baseName = 'verification-server-linux'
compression = Compression.GZIP
}
variants.each { String variant ->
task "${variant}DistTarLinux"(type: Tar) {
from "target/release/conjure-verification-${variant}"
baseName = "verification-${variant}-linux"
compression = Compression.GZIP
}

task distTarOsx(type: Tar) {
from "target/x86_64-apple-darwin/release/conjure-verification-server"
baseName = 'verification-server-osx'
compression = Compression.GZIP
}
task "${variant}DistTarOsx"(type: Tar) {
from "target/x86_64-apple-darwin/release/conjure-verification-${variant}"
baseName = "verification-${variant}-osx"
compression = Compression.GZIP
}

publishing {
publications {
distTarLinux(MavenPublication) {
artifactId "verification-server"
artifact (tasks.distTarLinux) {
classifier "linux"
publishing {
publications {
"${variant}DistTarLinux"(MavenPublication) {
artifactId "verification-$variant"
artifact (tasks["${variant}DistTarLinux"]) {
classifier "linux"
}
}
}
distTarOsx(MavenPublication) {
artifactId "verification-server"
artifact (tasks.distTarOsx) {
classifier "osx"
"${variant}DistTarOsx"(MavenPublication) {
artifactId "verification-server"
artifact (tasks["${variant}DistTarOsx"]) {
classifier "osx"
}
}
}
}
}

70 changes: 38 additions & 32 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
#!/usr/bin/env bash
set -ex
set -euxo pipefail
cd "$(dirname "${BASH_SOURCE[0]}" )"/..

case $(uname -s) in
Darwin*) echo "docker images can only be built on linux (ie on CircleCI)" && exit 1 ;;
esac

VERSION=$(git describe --tags --always --first-parent)
DEST=build/docker-context
rm -rf $DEST
mkdir -p $DEST

cp ./verification-server/Dockerfile $DEST/Dockerfile

BINARY=./target/release/conjure-verification-server
if [ ! -f $BINARY ]; then
echo "$BINARY must exist - run 'cargo build --release' to create it"
exit 1
fi
cp $BINARY $DEST

TEST_CASES=./verification-server-api/build/test-cases.json
if [ ! -f $TEST_CASES ]; then
echo "$TEST_CASES file must exist - run './gradlew compileTestCasesJson' to create it"
exit 1
fi
cp $TEST_CASES $DEST

IR_FILE=./verification-server-api/build/conjure-ir/verification-server-api.conjure.json
if [ ! -f $IR_FILE ]; then
echo "$IR_FILE file must exist - run './gradlew compileIr' to create it"
exit 1
fi
cp $IR_FILE $DEST

cd $DEST
docker build -t "palantirtechnologies/conjure-verification-server:$VERSION" .

docker tag "palantirtechnologies/conjure-verification-server:$VERSION" "palantirtechnologies/conjure-verification-server:latest"

function build_docker() (
DEST="build/$1/docker-context"
rm -rf "$DEST"
mkdir -p "$DEST"

cp "./verification-$1/Dockerfile" "$DEST/Dockerfile"

BINARY="./target/release/conjure-verification-$1"
if [ ! -f "$BINARY" ]; then
echo "$BINARY must exist - run 'cargo build --release' to create it"
exit 1
fi
cp "$BINARY" "$DEST"

TEST_CASES=./verification-$1-api/build/test-cases.json
if [ ! -f "$TEST_CASES" ]; then
echo "$TEST_CASES file must exist - run './gradlew compileTestCasesJson' to create it"
exit 1
fi
cp "$TEST_CASES" "$DEST"

IR_FILE="./verification-$1-api/build/conjure-ir/verification-$1-api.conjure.json"
if [ ! -f "$IR_FILE" ]; then
echo "$IR_FILE file must exist - run './gradlew compileIr' to create it"
exit 1
fi
cp "$IR_FILE" "$DEST"

cd "$DEST"
docker build -t "palantirtechnologies/conjure-verification-$1:$VERSION" .

docker tag "palantirtechnologies/conjure-verification-$1:$VERSION" "palantirtechnologies/conjure-verification-$1:latest"
)

build_docker "server"
build_docker "client"
23 changes: 23 additions & 0 deletions verification-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM rust:1.29.0-stretch

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends dumb-init; \
rm -rf /var/lib/apt/lists/*; \
mkdir -p /opt/palantir/services/conjure-verification-client/service/bin; \
mkdir -p /opt/palantir/services/conjure-verification-client/var/conf

ADD conjure-verification-client /opt/palantir/services/conjure-verification-client/service/bin
ADD test-cases.json /opt/palantir/services/conjure-verification-client/var/conf
ADD verification-client-api.conjure.json /opt/palantir/services/conjure-verification-client/var/conf

RUN chmod +x /opt/palantir/services/conjure-verification-client/service/bin/conjure-verification-client

EXPOSE 8000

ENV RUST_LOG conjure_verification_client=info,conjure_verification_http=info

WORKDIR /opt/palantir/services/conjure-verification-client

ENTRYPOINT ["dumb-init", "--", "service/bin/conjure-verification-client"]
CMD ["var/conf/test-cases.json", "var/conf/verification-client-api.conjure.json"]
2 changes: 1 addition & 1 deletion verification-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:stretch-slim
FROM rust:1.29.0-stretch

RUN set -eux; \
apt-get update; \
Expand Down

0 comments on commit 5a967bb

Please sign in to comment.