Skip to content

Commit

Permalink
Remove the bootstrap dependency on the Docker images we ship (vites…
Browse files Browse the repository at this point in the history
…sio#16339)

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com>
Co-authored-by: Deepthi Sigireddi <deepthi.sigireddi@gmail.com>
  • Loading branch information
frouioui and deepthi authored Jul 8, 2024
1 parent 0db3577 commit 6d95d7c
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 195 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,101 @@
name: Docker Build Images
name: Build Docker Images
on:
pull_request:
push:
branches:
- main
tags:
- 'v[2-9][0-9]*.*' # run only on tags greater or equal to v20.0.0 where this new way of building docker image was changed
- '*'

concurrency:
group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Images (v20+)')
group: format('{0}-{1}', ${{ github.ref }}, 'Build Docker Images')
cancel-in-progress: true

permissions: read-all

jobs:
push:
name: Set push variable
runs-on: ubuntu-20.04
if: github.repository == 'vitessio/vitess'
outputs:
push: ${{ steps.push.outputs.push }}

steps:
- name: Set push variable
id: push
run: |
push='false'
if [[ "${{github.event.pull_request}}" == "" ]]; then
push='true'
fi
echo Push='${push}'
echo "push=${push}" >> $GITHUB_OUTPUT
build_and_push_vttestserver:
name: Build and push vttestserver
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess' && needs.push.result == 'success'
needs:
- push

strategy:
fail-fast: true
matrix:
branch: [ mysql80 ]

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Login to Docker Hub
if: needs.push.outputs.push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set Dockerfile path
run: |
echo "DOCKERFILE=./docker/vttestserver/Dockerfile.${{ matrix.branch }}" >> $GITHUB_ENV
- name: Build and push on main
if: startsWith(github.ref, 'refs/tags/') == false
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE }}
push: ${{ needs.push.outputs.push }}
tags: vitess/vttestserver:${{ matrix.branch }}

######
# All code below only applies to new tags
######
- name: Get the Git tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set Docker tag name
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "DOCKER_TAG=vitess/vttestserver:${TAG_NAME}-${{ matrix.branch }}" >> $GITHUB_ENV
- name: Build and push on tags
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ env.DOCKER_TAG }}


build_and_push_lite:
name: Build and push vitess/lite Docker images
name: Build and push lite
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess'
if: github.repository == 'vitessio/vitess' && needs.push.result == 'success'
needs:
- push

strategy:
fail-fast: true
Expand All @@ -28,6 +107,7 @@ jobs:
uses: actions/checkout@v4

- name: Login to Docker Hub
if: needs.push.outputs.push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -42,12 +122,12 @@ jobs:
fi
- name: Build and push on main
if: github.ref == 'refs/heads/main'
if: startsWith(github.ref, 'refs/tags/') == false
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE }}
push: true
push: ${{ needs.push.outputs.push }}
tags: vitess/lite:${{ matrix.branch }}

######
Expand Down Expand Up @@ -76,10 +156,12 @@ jobs:
tags: ${{ env.DOCKER_TAG }}

build_and_push_components:
name: Build and push vitess components Docker images
needs: build_and_push_lite
name: Build and push
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess'
if: github.repository == 'vitessio/vitess' && needs.push.result == 'success' && needs.build_and_push_lite.result == 'success'
needs:
- push
- build_and_push_lite

strategy:
fail-fast: true
Expand All @@ -92,6 +174,7 @@ jobs:
uses: actions/checkout@v4

- name: Login to Docker Hub
if: needs.push.outputs.push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -102,22 +185,22 @@ jobs:
echo "DOCKER_CTX=./docker/binaries/${{ matrix.component }}" >> $GITHUB_ENV
- name: Build and push on main latest tag
if: github.ref == 'refs/heads/main' && matrix.debian == 'bookworm'
if: startsWith(github.ref, 'refs/tags/') == false && matrix.debian == 'bookworm'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
push: ${{ needs.push.outputs.push }}
tags: vitess/${{ matrix.component }}:latest
build-args: |
VT_BASE_VER=latest
DEBIAN_VER=${{ matrix.debian }}-slim
- name: Build and push on main debian specific tag
if: github.ref == 'refs/heads/main'
if: startsWith(github.ref, 'refs/tags/') == false
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
push: ${{ needs.push.outputs.push }}
tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }}
build-args: |
VT_BASE_VER=latest
Expand Down
65 changes: 0 additions & 65 deletions .github/workflows/docker_build_vttestserver.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ docker_lite:
docker_mini:
${call build_docker_image,docker/mini/Dockerfile,vitess/mini}

DOCKER_VTTESTSERVER_SUFFIX = mysql57 mysql80
DOCKER_VTTESTSERVER_SUFFIX = mysql80
DOCKER_VTTESTSERVER_TARGETS = $(addprefix docker_vttestserver_,$(DOCKER_VTTESTSERVER_SUFFIX))
$(DOCKER_VTTESTSERVER_TARGETS): docker_vttestserver_%:
${call build_docker_image,docker/vttestserver/Dockerfile.$*,vitess/vttestserver:$*}
Expand Down
25 changes: 11 additions & 14 deletions docker/lite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: We have to build the Vitess binaries from scratch instead of sharing
# a base image because Docker Hub dropped the feature we relied upon to
# ensure images contain the right binaries.

# Use a temporary layer for the build stage.
ARG bootstrap_version=34
ARG image="vitess/bootstrap:${bootstrap_version}-mysql80"

FROM "${image}" AS builder
FROM --platform=linux/amd64 golang:1.22.5-bullseye AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess
WORKDIR /vt/src/vitess.io/vitess

# Build and install Vitess in a temporary output directory.
# Create vitess user
RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot /home/vitess
RUN chown -R vitess:vitess /vt /home/vitess
USER vitess

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

RUN make install PREFIX=/vt/install

# Start over and build the final image.
FROM debian:bullseye-slim
FROM --platform=linux/amd64 debian:bullseye-slim

# Install dependencies
COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh
Expand All @@ -45,7 +42,7 @@ RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt

# Set up Vitess environment (just enough to run pre-built Go binaries)
ENV VTROOT /vt/src/vitess.io/vitess
ENV VTROOT /vt
ENV VTDATAROOT /vt/vtdataroot
ENV PATH $VTROOT/bin:$PATH

Expand Down
24 changes: 11 additions & 13 deletions docker/lite/Dockerfile.percona80
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: We have to build the Vitess binaries from scratch instead of sharing
# a base image because Docker Hub dropped the feature we relied upon to
# ensure images contain the right binaries.

# Use a temporary layer for the build stage.
ARG bootstrap_version=34
ARG image="vitess/bootstrap:${bootstrap_version}-percona80"

FROM "${image}" AS builder
FROM --platform=linux/amd64 golang:1.22.5-bullseye AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER

WORKDIR /vt/src/vitess.io/vitess

# Create vitess user
RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot /home/vitess
RUN chown -R vitess:vitess /vt /home/vitess
USER vitess

# Re-copy sources from working tree.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess

# Build and install Vitess in a temporary output directory.
USER vitess
RUN make install PREFIX=/vt/install

# Start over and build the final image.
FROM debian:bullseye-slim
FROM --platform=linux/amd64 debian:bullseye-slim

# Install dependencies
COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh
Expand All @@ -44,7 +42,7 @@ RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt

# Set up Vitess environment (just enough to run pre-built Go binaries)
ENV VTROOT /vt/src/vitess.io/vitess
ENV VTROOT /vt
ENV VTDATAROOT /vt/vtdataroot
ENV PATH $VTROOT/bin:$PATH

Expand Down
45 changes: 0 additions & 45 deletions docker/local/Dockerfile

This file was deleted.

Loading

0 comments on commit 6d95d7c

Please sign in to comment.