mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-02 19:25:52 +08:00
make release docker build script match EKS one as much as possible
This commit is contained in:
parent
2eef4e28be
commit
6b0ba14199
@ -93,24 +93,19 @@ If you are running FDB inside of a Kubernetes cluster, you should probably use
|
||||
the sidecar image instead. It makes it easier to automatically copy a compatible
|
||||
`libfdb_c.so` and cluster file into application containers.
|
||||
|
||||
TODO: Document the sidecar.
|
||||
TODO: Document sidecar.py
|
||||
|
||||
# Example Usages
|
||||
|
||||
### Build an Ubuntu-based image
|
||||
|
||||
TAG is optional and defaults to <fdb version triple>-<okteto environment name>
|
||||
e.g., 7.0.0-username-dev
|
||||
|
||||
```
|
||||
TAG=my-custom-tag ./build-release-docker.sh
|
||||
```
|
||||
### Build an Amazon Linux-based image
|
||||
From inside the developer Docker container:
|
||||
### Build an Ubuntu-based image with a custom tag and unstripped binaries
|
||||
```
|
||||
# compile FDB, then:
|
||||
cd ~/build_output/packages/docker/
|
||||
STRIPPED=true TAG=my-custom-tag ./build-eks-docker.sh
|
||||
TAG=my-custom-tag ./build-release-docker.sh
|
||||
```
|
||||
|
||||
TODO: Unify the above, so they're invoked in the same way.
|
||||
### Build an Amazon Linux-based image with a default tag and stripped binaries
|
||||
```
|
||||
# compile FDB, then:
|
||||
cd ~/build_output/packages/docker/
|
||||
STRIPPED=true ./build-eks-docker.sh
|
||||
```
|
@ -29,9 +29,17 @@ aws ecr get-login-password | docker login --username AWS --password-stdin ${ECR}
|
||||
docker pull ${ECR}/amazonlinux:2.0.20210326.0
|
||||
docker tag ${ECR}/amazonlinux:2.0.20210326.0 amazonlinux:2.0.20210326.0
|
||||
|
||||
|
||||
|
||||
#derived variables
|
||||
IMAGE=foundationdb/foundationdb:${TAG}
|
||||
SIDECAR=foundationdb/foundationdb-kubernetes-sidecar:${TAG}-1
|
||||
STRIPPED=${STRIPPED:-false}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if $STRIPPED; then
|
||||
rsync -av --delete --exclude=*.xml ${BUILD_OUTPUT}/packages/bin .
|
||||
rsync -av --delete --exclude=*.a --exclude=*.xml ${BUILD_OUTPUT}/packages/lib .
|
||||
@ -40,8 +48,10 @@ else
|
||||
rsync -av --delete --exclude=*.a --exclude=*.xml ${BUILD_OUTPUT}/lib .
|
||||
fi
|
||||
|
||||
docker build --build-arg FDB_VERSION=$FDB_VERSION -t ${IMAGE} --target foundationdb -f Dockerfile.eks .
|
||||
docker build --build-arg FDB_VERSION=$FDB_VERSION -t ${SIDECAR} --target sidecar -f Dockerfile.eks .
|
||||
BUILD_ARGS="--build-arg FDB_VERSION=$FDB_VERSION"
|
||||
|
||||
docker build ${BUILD_ARGS} -t ${IMAGE} --target foundationdb -f Dockerfile.eks .
|
||||
docker build ${BUILD_ARGS} -t ${SIDECAR} --target sidecar -f Dockerfile.eks .
|
||||
|
||||
docker tag ${IMAGE} ${ECR}/${IMAGE}
|
||||
docker tag ${SIDECAR} ${ECR}/${SIDECAR}
|
||||
|
@ -1,12 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
# This is designed to be run inside an environment with foundationdb checked out at ~/src/foundationdb.
|
||||
# The foundationdb build will write its output to ~/build_output
|
||||
FDB_SRC=${HOME}/src/foundationdb
|
||||
FDB_BUILD=${HOME}/build_output
|
||||
DOCKER_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]}))
|
||||
BUILD_OUTPUT=$(realpath ${DOCKER_ROOT}/../..)
|
||||
|
||||
FDB_VERSION=$(grep ' VERSION ' ${FDB_SRC}/CMakeLists.txt | tr -s ' ' ' ' | cut -d ' ' -f 3)
|
||||
echo Docker root: $DOCKER_ROOT
|
||||
echo Build output: $BUILD_OUTPUT
|
||||
|
||||
cd ${DOCKER_ROOT}
|
||||
|
||||
## eg: CMAKE_PROJECT_VERSION:STATIC=7.0.0
|
||||
FDB_VERSION=$(grep CMAKE_PROJECT_VERSION\: ${BUILD_OUTPUT}/CMakeCache.txt | cut -d '=' -f 2)
|
||||
|
||||
# Options (passed via environment variables)
|
||||
|
||||
@ -17,26 +22,6 @@ ECR=${ECR:-112664522426.dkr.ecr.us-west-2.amazonaws.com}
|
||||
|
||||
echo Building with tag ${TAG}
|
||||
|
||||
# TODO: This is a copy of the commonly-used 'cmk' function.
|
||||
cmake -S ${FDB_SRC} -B ${FDB_BUILD} \
|
||||
-D USE_CCACHE=ON -D USE_WERROR=ON -D RocksDB_ROOT=/opt/rocksdb-6.10.1 -D RUN_JUNIT_TESTS=ON -D RUN_JAVA_INTEGRATION_TESTS=ON \
|
||||
-G Ninja
|
||||
|
||||
ninja -C ${FDB_BUILD} -j 84
|
||||
|
||||
# derived variables
|
||||
IMAGE=foundationdb/foundationdb:${TAG}
|
||||
SIDECAR_IMAGE=foundationdb/foundationdb-kubernetes-sidecar:${TAG}-1
|
||||
|
||||
cd ${FDB_BUILD}/packages/docker
|
||||
|
||||
WEBSITE_BIN_DIR=website/downloads/${FDB_VERSION}/linux/
|
||||
TARBALL=${WEBSITE_BIN_DIR}/fdb_${FDB_VERSION}.tar.gz
|
||||
|
||||
mkdir -p ${WEBSITE_BIN_DIR}
|
||||
tar -C ~/build_output/packages/ -zcvf ${TARBALL} bin lib
|
||||
cp ~/build_output/packages/lib/libfdb_c.so ${WEBSITE_BIN_DIR}/libfdb_c_${FDB_VERSION}.so
|
||||
|
||||
# Login to ECR
|
||||
# TODO: Move this to a common place instead of repeatedly copy-pasting it.
|
||||
aws ecr get-login-password | docker login --username AWS --password-stdin ${ECR}
|
||||
@ -46,21 +31,32 @@ docker tag ${ECR}/ubuntu:18.04 ubuntu:18.04
|
||||
docker pull ${ECR}/python:3.9-slim
|
||||
docker tag ${ECR}/python:3.9-slim python:3.9-slim
|
||||
|
||||
docker build -t ${IMAGE} \
|
||||
--build-arg FDB_WEBSITE=file:///mnt/website \
|
||||
--build-arg FDB_VERSION=$FDB_VERSION \
|
||||
--build-arg FDB_ADDITIONAL_VERSIONS=$FDB_VERSION \
|
||||
-f release/Dockerfile .
|
||||
# derived variables
|
||||
IMAGE=foundationdb/foundationdb:${TAG}
|
||||
SIDECAR=foundationdb/foundationdb-kubernetes-sidecar:${TAG}-1
|
||||
STRIPPED=${STRIPPED:-false}
|
||||
|
||||
WEBSITE_BIN_DIR=website/downloads/${FDB_VERSION}/linux/
|
||||
TARBALL=${WEBSITE_BIN_DIR}/fdb_${FDB_VERSION}.tar.gz
|
||||
mkdir -p ${WEBSITE_BIN_DIR}
|
||||
|
||||
if $STRIPPED; then
|
||||
tar -C ~/build_output/packages/ -zcvf ${TARBALL} bin lib
|
||||
cp ~/build_output/packages/lib/libfdb_c.so ${WEBSITE_BIN_DIR}/libfdb_c_${FDB_VERSION}.so
|
||||
else
|
||||
tar -C ~/build_output/ -zcvf ${TARBALL} bin lib
|
||||
cp ~/build_output/lib/libfdb_c.so ${WEBSITE_BIN_DIR}/libfdb_c_${FDB_VERSION}.so
|
||||
fi
|
||||
|
||||
BUILD_ARGS="--build-arg FDB_WEBSITE=file:///mnt/website "
|
||||
BUILD_ARGS+="--build-arg FDB_VERSION=$FDB_VERSION "
|
||||
BUILD_ARGS+="--build-arg FDB_ADDITIONAL_VERSIONS=$FDB_VERSION"
|
||||
|
||||
docker build -t ${IMAGE} ${BUILD_ARGS} -f release/Dockerfile .
|
||||
docker build -t ${SIDECAR} ${BUILD_ARGS} -f sidecar/Dockerfile .
|
||||
|
||||
docker tag ${IMAGE} ${ECR}/${IMAGE}
|
||||
|
||||
docker build -t ${SIDECAR_IMAGE} \
|
||||
--build-arg FDB_WEBSITE=file:///mnt/website \
|
||||
--build-arg FDB_VERSION=$FDB_VERSION \
|
||||
--build-arg FDB_ADDITIONAL_VERSIONS=$FDB_VERSION \
|
||||
-f sidecar/Dockerfile .
|
||||
|
||||
docker tag ${SIDECAR_IMAGE} ${ECR}/${SIDECAR_IMAGE}
|
||||
docker tag ${SIDECAR} ${ECR}/${SIDECAR}
|
||||
|
||||
docker push ${ECR}/${IMAGE}
|
||||
docker push ${ECR}/${SIDECAR_IMAGE}
|
||||
docker push ${ECR}/${SIDECAR}
|
||||
|
@ -54,11 +54,10 @@ RUN curl $FDB_WEBSITE/downloads/$FDB_VERSION/linux/fdb_$FDB_VERSION.tar.gz -o fd
|
||||
|
||||
WORKDIR /var/fdb
|
||||
|
||||
|
||||
# Set Up Runtime Scripts and Directories
|
||||
|
||||
COPY release/*.bash /var/fdb/scripts/
|
||||
|
||||
RUN chmod a+x /var/fdb/scripts/*.bash
|
||||
RUN mkdir -p logs
|
||||
|
||||
# Install FoundationDB Client Libraries
|
||||
|
@ -54,7 +54,7 @@ COPY sidecar/entrypoint.bash /
|
||||
COPY sidecar/requirements.txt /
|
||||
COPY sidecar/sidecar.py /
|
||||
|
||||
RUN pip install -r /requirements.txt && rm /requirements.txt && chmod a+x /entrypoint.bash
|
||||
RUN pip install -r /requirements.txt && rm /requirements.txt && chmod a+x /entrypoint.bash /sidecar.py
|
||||
|
||||
VOLUME /var/input-files
|
||||
VOLUME /var/output-files
|
||||
|
@ -1,4 +1,4 @@
|
||||
#! /usr/bin/python3
|
||||
#! /usr/bin/env python3
|
||||
|
||||
# entrypoint.py
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user