1
0
mirror of https://github.com/comit-network/comit-rs synced 2025-10-06 00:32:52 +02:00

Build docker image from existing release binary upon release

This commit is contained in:
Thomas Eizinger
2019-11-27 20:33:02 +11:00
parent 420c7fd74a
commit 2392d07697
5 changed files with 29 additions and 45 deletions

View File

@@ -93,8 +93,9 @@ jobs:
- install_rust
- install_node_devlibs
- print_current_versions
- setup_remote_docker
- run:
name: "Package & Publish Release on GitHub"
name: "Package & Publish Release on GitHub and Docker Hub"
command: |
set -v
VERSION=$(cargo pkgid -- cnd|cut -d# -f2)
@@ -108,6 +109,12 @@ jobs:
ls ~/package/
ghr -t ${GITHUB_TOKEN_FOR_RELEASES} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ~/package/
echo $DOCKER_HUB_TOKEN | docker login -u thomaseizinger --password-stdin
docker build . -t comitnetwork/cnd:${VERSION} -t comitnetwork/cnd:latest
docker push comitnetwork/cnd:${VERSION}
docker push comitnetwork/cnd:latest
commands:
install_node_devlibs:
steps:

View File

@@ -1,34 +0,0 @@
FROM rust:1.39-buster as builder
WORKDIR /src
# Only copy the actual source code over, avoids rebuilds if other stuff changes in the repository
COPY ./btsieve ./btsieve
COPY ./internal ./internal
COPY ./cnd ./cnd
COPY ./libp2p-comit ./libp2p-comit
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
# Running a cargo check before the build allows us to cache the dependencies if we need repeated builds
RUN cargo check
RUN cargo build -p cnd --release
FROM debian:buster
RUN apt-get update && \
apt-get install -y \
tini \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash cnd
USER cnd
COPY --from=builder /src/target/release/cnd /usr/local/bin
EXPOSE 9939
EXPOSE 8000
# tini allows us to CTRL+C our container if it runs in the foreground
ENTRYPOINT ["tini"]
CMD ["cnd"]

View File

@@ -1,4 +0,0 @@
# COMIT dockerfiles
These dockerfile is written to be built from the root folder of the repository:
`docker build -f .docker/Dockerfile .`

View File

@@ -1,6 +1,3 @@
target/
.circleci/
.dependabot/
.githooks/
api_tests/
.docker/Dockerfile
# The only thing we are interested in the Dockerfile is the release binary, hence we can ignore everything else to speed up the build process
*
!target/release/cnd

18
Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
FROM debian:buster
RUN apt-get update && \
apt-get install -y \
tini \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash cnd
USER cnd
COPY ./target/release/cnd /usr/local/bin
EXPOSE 9939
EXPOSE 8000
# tini allows us to CTRL+C our container if it runs in the foreground
ENTRYPOINT ["tini"]
CMD ["cnd"]