Added automatic docker image creation
This commit is contained in:
parent
45064b6b7b
commit
f92e12511b
4 changed files with 101 additions and 1 deletions
|
@ -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
|
||||
|
|
34
packaging/docker-for-binary/Dockerfile.Auto
Normal file
34
packaging/docker-for-binary/Dockerfile.Auto
Normal 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"]
|
|
@ -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
|
||||
|
||||
|
|
26
packaging/docker-for-binary/auto_deploy.sh
Executable file
26
packaging/docker-for-binary/auto_deploy.sh
Executable 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"
|
Loading…
Reference in a new issue