Skip to content

Commit

Permalink
Refactor build env logic to switch between testing and production
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon committed Aug 1, 2024
1 parent ef6f485 commit 62eb77d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 132 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ['linux/amd64', 'linux/arm64']
platform: ['linux/amd64', 'linux/arm64']
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -30,9 +30,12 @@ jobs:
- uses: actions/checkout@v4
with:
path: 'opensearch-benchmark-git'
- name: Docker Build and Test on ${{ matrix.architecture }}
- name: Docker Build ${{ matrix.platform }}
run: |
docker buildx version
cp -a opensearch-benchmark-git/* ./
echo "Disable VERSION arg to enter docker build test mode"
docker buildx build --platform ${{ matrix.architecture }} --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f "docker/Dockerfile" .
PLATFORM=${{ matrix.platform }}
PLATFORM=`echo $PLATFORM | tr '/' '-'`
docker buildx build --platform ${{ matrix.platform }} --build-arg BUILD_ENV=testing --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f "docker/Dockerfile" -t "osb/osb-$PLATFORM" -o type=docker .
docker images | grep "osb/osb-$PLATFORM"
25 changes: 10 additions & 15 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
###############################################################################
# Install OpenSearch Benchmark from PyPI to build a Docker image
###############################################################################
ARG VERSION
ARG BUILD_ENV=production

FROM python:3.11.2-slim
ARG VERSION=testing
FROM python:3.11.2-slim as build_env_testing
ONBUILD COPY opensearch-benchmark-git/ ./

ENV BENCHMARK_RUNNING_IN_DOCKER=True
FROM python:3.11.2-slim as build_env_production
ONBUILD RUN echo Production Environment

FROM build_env_${BUILD_ENV}
WORKDIR /opensearch-benchmark
ENV BENCHMARK_RUNNING_IN_DOCKER=True

RUN apt-get -y update && \
apt-get install -y curl git gcc pbzip2 pigz && \
Expand All @@ -18,15 +20,8 @@ RUN groupadd --gid 1000 opensearch-benchmark && \
useradd -d /opensearch-benchmark -m -k /dev/null -g 1000 -N -u 1000 -l -s /bin/bash benchmark

ENV PIP_ONLY_BINARY=h5py

# Copy file for test purpose and will remove during prod publishing
COPY opensearch-benchmark-git/ ./opensearch-benchmark-git

# Currently we always have the $VERSION arg substituted during prod publishing
# Default VERSION=testing to enter test mode based on user inputs.
RUN if [ "$VERSION" = "testing" ] ; then echo Testing; cp -a opensearch-benchmark-git/* ./; ls -l; python3 -m pip install -e . ; \
else echo Production; rm -rf opensearch-benchmark-git; ls -l; python3 -m pip install opensearch-benchmark==$VERSION ; fi

RUN if [ "$BUILD_ENV" = "testing" ] ; then echo Testing; ls -l; python3 -m pip install -e . ; \
else echo Production; if [ -z "$VERSION" ] ; then python3 -m pip install opensearch-benchmark ; else python3 -m pip install opensearch-benchmark==$VERSION ; fi; fi

RUN mkdir -p /opensearch-benchmark/.benchmark && \
chown -R 1000:0 /opensearch-benchmark/.benchmark
Expand Down
75 changes: 0 additions & 75 deletions docker/Dockerfile-development

This file was deleted.

37 changes: 0 additions & 37 deletions docker/docker-compose-tests.yml

This file was deleted.

2 changes: 0 additions & 2 deletions jenkins/release.JenkinsFile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ standardReleasePipelineWithGenericTrigger(
string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: 'main'),
string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [
'su $(id -un 1000) -c "cd docker/ci',
'mkdir -p opensearch-benchmark-git',
'echo Production > opensearch-benchmark-git/status.txt'
'git clone https://github.com/opensearch-project/opensearch-benchmark opensearch-benchmark',
'cp -a opensearch-benchmark/* ./"',
'cd docker/ci',
Expand Down

0 comments on commit 62eb77d

Please sign in to comment.