Merge remote-tracking branch 'origin/fix_blockdir_beamer'

This commit is contained in:
Brannon King 2020-02-06 09:16:50 -07:00
commit a8555a5515
7 changed files with 115 additions and 11 deletions

View file

@ -24,11 +24,13 @@ jobs:
- mkdir -p ${HOME}/ccache
- docker pull $DOCKER_BUILD_IMAGE
script:
- echo "build..."
- docker run -v "$(pwd):/lbrycrd" -v "${HOME}/ccache:/ccache" -w /lbrycrd -e CCACHE_DIR=/ccache ${DOCKER_IMAGE} packaging/build_${NAME}_64bit.sh
before_deploy:
- mkdir -p dist
- sudo zip -Xj dist/lbrycrd-${NAME}.zip src/lbrycrdd${EXT} src/lbrycrd-cli${EXT} src/lbrycrd-tx${EXT}
- sudo zip -Xj dist/lbrycrd-${NAME}-test.zip src/test/test_lbrycrd${EXT} src/test/test_lbrycrd_fuzzy${EXT}
- sudo cp dist/lbrycrd-${NAME}.zip packaging/docker-for-binary/lbrycrd-${NAME}.zip
- sha256sum dist/lbrycrd-${NAME}.zip
- sha256sum dist/lbrycrd-${NAME}-test.zip
deploy:
@ -44,6 +46,13 @@ jobs:
on:
repo: lbryio/lbrycrd
all_branches: true
- provider: script
script: bash packaging/docker-for-binary/auto_deploy.sh ${TRAVIS_BRANCH}
skip_cleanup: true
on:
repo: lbryio/lbrycrd
all_branches: true
condition: $NAME = linux
- <<: *build-template
name: windows

View file

@ -0,0 +1,34 @@
FROM ubuntu:18.04 as prep
LABEL MAINTAINER="leopere [at] nixc [dot] us"
## TODO: Implement version pinning. `apt-get install curl=<version>`
RUN apt-get update && \
apt-get -y install unzip curl build-essential && \
apt-get autoclean -y && \
rm -rf /var/lib/apt/lists/*
WORKDIR /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY ./stuff/start.sh start
COPY ./stuff/healthcheck.sh healthcheck
COPY ./stuff/advance_blocks.sh advance
COPY ./stuff/fix-permissions.c fix-permissions.c
COPY ./lbrycrd-linux.zip lbrycrd-linux.zip
RUN unzip ./lbrycrd-linux.zip && \
gcc fix-permissions.c -o fix-permissions && \
chmod +x ./lbrycrdd ./lbrycrd-cli ./lbrycrd-tx ./start ./healthcheck ./fix-permissions ./advance
FROM ubuntu:18.04 as app
COPY --from=prep /lbrycrdd /lbrycrd-cli /lbrycrd-tx /start /healthcheck /fix-permissions /advance /usr/bin/
RUN addgroup --gid 1000 lbrycrd && \
adduser lbrycrd --uid 1000 --gid 1000 --gecos GECOS --shell /bin/bash --disabled-password --home /data && \
mkdir /etc/lbry && \
chown lbrycrd /etc/lbry && \
chmod a+s /usr/bin/fix-permissions
RUN apt-get update && apt-get -y install wget && apt-get autoclean -y && rm -rf /var/lib/apt/lists/*
VOLUME ["/data"]
WORKDIR /data
HEALTHCHECK CMD /usr/bin/healthcheck
EXPOSE 9246 9245 11337 29245
USER lbrycrd
CMD ["start"]

View file

@ -1,5 +1,36 @@
# lbrycrd Docker image
`
## Scripts
There are two scripts `deploy.sh` and `auto_deploy.sh` These are used to create
docker images to push to lbry's Docker Hub.
### `auto_deploy.sh`
This script is used by the LBRYcrd's CI. When a branch or tag is built
it will create a docker image for it and push it to DockerHub. This should
not be used outside of the CI environment. In addition to this, the
`Dockerfile.Auto` is associated with this script. This will only run on the
Linux build job.
#### Requirements
- You would need to build lbrycrd with the Docker image for reproducible
builds. https://hub.docker.com/repository/docker/lbry/build_lbrycrd
- You will need DockerHub credentials to run this locally.
- When the script is executed you will need the parameter as
`./auto_deploy.sh ${tag_name}`
### `deploy.sh`
This can be used locally to manually create a docker image based on a
release. `release_url` is requested as a parameter to the script when
run locally. This will grab the binary from github releases inside the
image build.
#### Requirements
- You will need DockerHub credentials to run this locally.
## Configuration

View file

@ -0,0 +1,26 @@
#!/bin/bash
set -euo pipefail
hash docker 2>/dev/null || { echo >&2 'Make sure Docker is installed'; exit 1; }
set +eo pipefail
docker version | grep -q Server
ret=$?
set -eo pipefail
if [ $ret -ne 0 ]; then
echo "Cannot connect to Docker server. Is it running? Do you have the right user permissions?"
exit 1
fi
if [ -z "$1" ]; then
echo "Docker tag parameter cannot be empty"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd packaging/docker-for-binary
docker build --tag "lbry/lbrycrd:$1" -f Dockerfile.Auto "$DIR"
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
docker push "lbry/lbrycrd:$1"

View file

@ -1621,7 +1621,7 @@ bool AppInitMain()
if (fReindex) {
// remove old LevelDB indexes
boost::system::error_code ec;
fs::remove_all(GetDataDir() / "blocks" / "index", ec);
fs::remove_all(GetBlocksDir() / "index", ec);
fs::remove_all(GetDataDir() / "chainstate", ec);
fs::remove_all(GetDataDir() / "claimtrie", ec);
}

View file

@ -704,12 +704,14 @@ const fs::path &GetBlocksDir(bool fNetSpecific)
if (gArgs.IsArgSet("-blocksdir")) {
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
if (!fs::is_directory(path)) {
path = "";
return path;
LogPrintf("%s: %s is not a directory, fallback to GetDataDir\n", __func__, path);
path.clear();
}
} else {
path = GetDataDir(false);
}
if (path.empty())
path = GetDataDir(false);
if (fNetSpecific)
path /= BaseParams().DataDir();
@ -733,12 +735,14 @@ const fs::path &GetDataDir(bool fNetSpecific)
if (gArgs.IsArgSet("-datadir")) {
path = fs::system_complete(gArgs.GetArg("-datadir", ""));
if (!fs::is_directory(path)) {
path = "";
return path;
LogPrintf("%s: %s is not a directory, fallback to GetDefaultDataDir\n", __func__, path);
path.clear();
}
} else {
path = GetDefaultDataDir();
}
if (path.empty())
path = GetDefaultDataDir();
if (fNetSpecific)
path /= BaseParams().DataDir();

View file

@ -4362,7 +4362,7 @@ bool LoadBlockIndex(const CChainParams& chainparams)
needs_init = g_chainstate.mapBlockIndex.empty();
if (needs_init) {
auto blockDir = GetDataDir() / "blocks";
auto& blockDir = GetBlocksDir();
for (auto it: fs::directory_iterator(blockDir)) {
boost::system::error_code ec;
if (fs::file_size(it, ec) > 100000000) {