Use binary for building docker image (#40)

* Use binary for building docker image

In the previous workflow, we were building and testing twice: once for
the docker image and once for the test step. Now, we'll build a debug
version in the test step, then build a release version and finally copy
that into the docker image. This would heavily reduce our build times.

* Ignore specific files in target to speed up builds

* Build image only when pushed to next or tagged

* Fix build condition

Since both conditions have to evaluate to true, we'll need to use refs
while also matching against both `push` and `tag` events

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
next
Sayan 4 years ago committed by GitHub
parent 792351108d
commit 597a82ddf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,13 +8,19 @@ steps:
- cargo build --verbose
- cargo test --verbose
---
kind: pipeline
type: docker
name: Docker Image
- name: build-docker-binary
image: rust
commands:
- cargo build --release
when:
ref:
- refs/heads/next
- refs/tags/*
event:
- tag
- push
steps:
- name: Push to Docker Hub
- name: push-docker-image
image: plugins/docker
settings:
repo: terrabasedb/tdb
@ -23,3 +29,10 @@ steps:
password:
from_secret: docker_password
auto_tag: true
when:
ref:
- refs/heads/next
- refs/tags/*
event:
- tag
- push

@ -0,0 +1,9 @@
# Ignore deps in the target directory
target/debug/deps/
target/debug/incremental/
target/debug/build/
target/release/deps/
target/release/incremental/
target/release/build/
target/doc/
target/rls/

@ -2,18 +2,9 @@
# The Dockerfile for the TerrabaseDB server tdb
#
FROM rust:latest
RUN \
apt-get update && apt-get install git curl -y && \
cd /tmp && \
git clone https://github.com/terrabasedb/terrabasedb.git && \
cd terrabasedb && \
git checkout next && \
cargo test --release -p tdb && \
cargo build --release -p tdb && \
apt-get remove git curl -y && \
apt-get autoremove -y && \
cp -f target/release/tdb /usr/local/bin
FROM debian:stable
COPY target/release/tdb /usr/local/bin
CMD ["tdb", "-h", "0.0.0.0", "-p", "2003"]

Loading…
Cancel
Save