From 2bae2b57ee292a91babd3e64c41a3f20f942b245 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Tue, 27 Aug 2019 17:58:45 -0400 Subject: [PATCH] adding two Dockerfiles, one for base image and the other for multistage build, and circleci config to test Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 122 ++++++++++++++++++++++++ docker/Dockerfile | 4 + Dockerfile => docker/Dockerfile.nu-base | 7 +- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 docker/Dockerfile rename Dockerfile => docker/Dockerfile.nu-base (59%) diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..8d25614fd1 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,122 @@ +# CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/configuration-reference/ for more details +# See https://circleci.com/docs/2.0/config-intro/#section=configuration for spec +# +version: 2.1 + +orbs: + # https://circleci.com/orbs/registry/orb/circleci/docker + docker: circleci/docker@0.5.13 + + +workflows: + version: 2.0 + + # This builds on all pull requests to test, and ignores master + build_without_deploy: + jobs: + - docker/publish: + deploy: false + image: nushell/nu-base + tag: latest + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + ignore: + - master + + - docker/publish: + deploy: false + image: nushell/nu + tag: latest + dockerfile: docker/Dockerfile + requires: + - docker/publish + after_build: + - run: + name: Preview Docker Tag for Build + command: | + DOCKER_TAG=v$(docker run nushell/nushell --version | cut -d' ' -f2) + echo "Version that would be used for Docker tag is v${DOCKER_TAG}" + + # workflow publishes to Docker Hub, with each job having different triggers + build_with_deploy: + jobs: + + # Deploy versioned and latest images on tags (releases) only. + - docker/publish: + image: nushell/nu-base + tag: latest + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ + after_build: + - run: + name: Publish Docker Tag with Nushell Version + command: | + DOCKER_TAG=v$(docker run nushell/nu-base --version | cut -d' ' -f2) + echo "Version for Docker tag is ${DOCKER_TAG}" + docker tag nushell/nu-base:latest nushell/nu-base:${DOCKER_TAG} + + - docker/publish: + image: nushell/nu + tag: latest + dockerfile: docker/Dockerfile + requires: + - docker/publish + after_build: + - run: + name: Publish Docker Tag with Nushell Version + command: | + DOCKER_TAG=v$(docker run nushell/nu --version | cut -d' ' -f2) + echo "Version for Docker tag is ${DOCKER_TAG}" + docker tag nushell/nu-base:latest nushell/nu:${DOCKER_TAG} + + + # publish devel to Docker Hub on merge to master + build_with_deploy_devel: + jobs: + + # Deploy devel tag on merge to master + - docker/publish: + image: nushell/nu-base + tag: devel + dockerfile: docker/Dockerfile.nu-base + filters: + branches: + only: master + + - docker/publish: + image: nushell/nu + tag: devel + dockerfile: docker/Dockerfile + requires: + - docker/publish + + + # Nightly build + build_with_deploy_nightly: + triggers: + - schedule: + cron: "0 22 * * *" # 22:00 UTC + filters: + branches: + only: + - master + + jobs: + - docker/publish: + image: nushell/nu-base + tag: nightly + dockerfile: docker/Dockerfile.nu-base + + - docker/publish: + image: nushell/nu + tag: nightly + requires: + - docker/publish + dockerfile: docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..d74364b6fa --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM nushell/nu-base as base +FROM rust:1.37-slim +COPY --from=base /usr/local/bin/nu /usr/local/bin/nu +ENTRYPOINT ["nu"] diff --git a/Dockerfile b/docker/Dockerfile.nu-base similarity index 59% rename from Dockerfile rename to docker/Dockerfile.nu-base index c048812b90..08b7f95377 100644 --- a/Dockerfile +++ b/docker/Dockerfile.nu-base @@ -1,7 +1,7 @@ FROM rust:1.37-slim -# docker build -t nu . -# docker run -it nu +# docker build -t nushell/nu-base . +# docker run -it nushell/nu-base ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y libssl-dev \ @@ -12,5 +12,6 @@ RUN apt-get update && apt-get install -y libssl-dev \ ADD . /code WORKDIR /code -RUN cargo install nu +RUN cargo build --release && cargo run --release && \ + cp target/release/nu /usr/local/bin ENTRYPOINT ["nu"]