-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the bootstrap
dependency on the Docker images we ship
#16339
Changes from 9 commits
17e9453
7dcf64b
1ab2da3
0a4826e
aefb694
6c1158d
72d9cd5
af52626
c5ae3ee
e99c1a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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: | ||
skip_push: | ||
name: Set skip_push if we are on a Pull Request | ||
runs-on: ubuntu-20.04 | ||
if: github.repository == 'vitessio/vitess' | ||
outputs: | ||
skip_push: ${{ steps.skip_push.outputs.skip_push }} | ||
|
||
steps: | ||
- name: Set skip_push | ||
id: skip_push | ||
run: | | ||
push='false' | ||
if [[ "${{github.event.pull_request}}" == "" ]]; then | ||
push='true' | ||
fi | ||
echo Push='${push}' | ||
echo "skip_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.skip_push.result == 'success' | ||
needs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed via e99c1a7 |
||
- skip_push | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
branch: [ mysql80 ] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
if: needs.skip_push.outputs.skip_push == 'true' | ||
uses: docker/login-action@v3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would we need to login to docker hub if we're NOT pushing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a really good point, the naming of |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not explicitly check: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could check for this, but that will only build if the PR is based on |
||
with: | ||
context: . | ||
file: ${{ env.DOCKERFILE }} | ||
push: ${{ needs.skip_push.outputs.skip_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.skip_push.result == 'success' | ||
needs: | ||
- skip_push | ||
|
||
strategy: | ||
fail-fast: true | ||
|
@@ -28,6 +107,7 @@ jobs: | |
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
if: needs.skip_push.outputs.skip_push == 'true' | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
|
@@ -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.skip_push.outputs.skip_push }} | ||
tags: vitess/lite:${{ matrix.branch }} | ||
|
||
###### | ||
|
@@ -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.skip_push.result == 'success' && needs.build_and_push_lite.result == 'success' | ||
needs: | ||
- skip_push | ||
- build_and_push_lite | ||
|
||
strategy: | ||
fail-fast: true | ||
|
@@ -92,6 +174,7 @@ jobs: | |
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
if: needs.skip_push.outputs.skip_push == 'true' | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
|
@@ -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.skip_push.outputs.skip_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.skip_push.outputs.skip_push }} | ||
tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }} | ||
build-args: | | ||
VT_BASE_VER=latest | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only have |
||
DOCKER_VTTESTSERVER_TARGETS = $(addprefix docker_vttestserver_,$(DOCKER_VTTESTSERVER_SUFFIX)) | ||
$(DOCKER_VTTESTSERVER_TARGETS): docker_vttestserver_%: | ||
${call build_docker_image,docker/vttestserver/Dockerfile.$*,vitess/vttestserver:$*} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added these |
||
|
||
# Install dependencies | ||
COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this was wrong to begin with, leading to the error:
With this fix, the vitess binaries are directly in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the fix:
|
||
ENV VTDATAROOT /vt/vtdataroot | ||
ENV PATH $VTROOT/bin:$PATH | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This job will be executed before everyone else. Then
build_and_push_vttestserver
andbuild_and_push_lite
are executed concurrently. Finally, oncebuild_and_push_lite
is done,build_and_push_components
will begin building all the binaries concurrently.