diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 12b9075..5e9dd1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,8 +38,6 @@ build:build-linux: stage: build script: - make - only: - - pushes artifacts: paths: - ./server @@ -72,10 +70,6 @@ test:test-unittest: - build:build-linux script: - make test - only: - - pushes - after_script: - - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN .test:test-race-conditions: stage: test @@ -93,10 +87,6 @@ test:test-coverage: - make coverage - make coverage_report - make coverage_html - only: - - pushes - after_script: - - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN artifacts: paths: - ./coverage.html @@ -104,6 +94,18 @@ test:test-coverage: # ************************************************************************/ # DEPLOY # ************************************************************************/ +deploy_staging: + stage: deploy + script: + - make + - make test + environment: + name: staging + only: + - master + after_script: + - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN + .release-candidate: stage: deploy script: @@ -116,7 +118,6 @@ test:test-coverage: - echo "Generating v0.0.1" when: manual - # ************************************************************************/ # MONITOR # ************************************************************************/ diff --git a/Dockerfile b/Dockerfile index 37d8744..57e415d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,17 +78,27 @@ RUN /usr/bin/install -c /build/zcash/src/zcashd /build/zcash/src/zcash-cli /usr/ # Create layer for lightwalletd and zcash binaries to reduce image size FROM golang:1.11 AS zcash_runner -ENV ZCASH_CONF=/root/.zcash/zcash.conf -RUN mkdir -p /root/.zcash/ && \ - mkdir -p /root/.zcash-params/ && \ +ARG ZCASH_VERSION=2.0.7+3 +ARG ZCASHD_USER=zcash +ARG ZCASHD_UID=1001 +ARG ZCASH_CONF=/home/$ZCASHD_USER/.zcash/zcash.conf + +RUN useradd -s /bin/bash -u $ZCASHD_UID $ZCASHD_USER + +RUN mkdir -p /home/$ZCASHD_USER/.zcash/ && \ + mkdir -p /home/$ZCASHD_USER/.zcash-params/ && \ + chown -R $ZCASHD_USER /home/$ZCASHD_USER/.zcash/ && \ mkdir /logs/ && \ mkdir /db/ +USER $ZCASHD_USER +WORKDIR /home/$ZCASHD_USER/ + # Use lightwallet server and ingest binaries from prior layer COPY --from=lightwalletd_base /usr/bin/ingest /usr/bin/server /usr/bin/ COPY --from=zcash_builder /usr/bin/zcashd /usr/bin/zcash-cli /usr/bin/ -COPY --from=zcash_builder /root/.zcash-params/ /root/.zcash-params/ +COPY --from=zcash_builder /root/.zcash-params/ /home/$ZCASHD_USER/.zcash-params/ # Configure zcash.conf RUN echo "testnet=1" >> ${ZCASH_CONF} && \ @@ -98,5 +108,5 @@ RUN echo "testnet=1" >> ${ZCASH_CONF} && \ echo "rpcuser=lwd" >> ${ZCASH_CONF} && \ echo "rpcpassword=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''`" >> ${ZCASH_CONF} -VOLUME [/root/.zcash] -VOLUME [/root/.zcash-params] +VOLUME [/home/$ZCASH_USER/.zcash] +VOLUME [/home/$ZCASH_USER/.zcash-params] diff --git a/Makefile b/Makefile index 4834d1d..b461072 100644 --- a/Makefile +++ b/Makefile @@ -75,11 +75,11 @@ docker_img_stop_zcashd: # Start the lightwalletd ingester in the zcashdlwd container docker_img_run_lightwalletd_ingest: - docker exec -i zcashdlwd ingest --conf-file /root/.zcash/zcash.conf --db-path /db/sql.db --log-file /logs/ingest.log + docker exec -i zcashdlwd ingest --conf-file /home/zcash/.zcash/zcash.conf --db-path /db/sql.db --log-file /logs/ingest.log # Start the lightwalletd server in the zcashdlwd container docker_img_run_lightwalletd_insecure_server: - docker exec -i zcashdlwd server --very-insecure=true --conf-file /root/.zcash/zcash.conf --db-path /db/sql.db --log-file /logs/server.log --bind-addr 127.0.0.1:18232 + docker exec -i zcashdlwd server --very-insecure=true --conf-file /home/zcash/.zcash/zcash.conf --db-path /db/sql.db --log-file /logs/server.log --bind-addr 127.0.0.1:18232 # Remove and delete ALL images and containers in Docker; assumes containers are stopped docker_remove_all: @@ -94,6 +94,10 @@ build: GO111MODULE=on CGO_ENABLED=1 go build -i -v ./cmd/ingest GO111MODULE=on CGO_ENABLED=1 go build -i -v ./cmd/server +build_rel: + GO111MODULE=on CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -i -v ./cmd/ingest + GO111MODULE=on CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -i -v ./cmd/server + # Install binaries into Go path install: go install ./... diff --git a/README.md b/README.md index 80c2b00..dd1e0f4 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ The first-order dependencies of this code are: **Containers** -This software was designed to be container-friendly! We highly recommend that you package and deploy the software in this manner. We've created an example Docker environment that is likewise new and minimally tested, but it's functional. It lives at [zcash-hackworks/lightwalletd-z-cash](https://github.com/zcash-hackworks/lightwalletd-z-cash). +This software was designed to be container-friendly! We highly recommend that you package and deploy the software in this manner. We've created an example Docker environment that is likewise new and minimally tested, but it's functional. **What's missing?**