Skip to content

Commit 3579094

Browse files
committed
Add GitHub workflow for building MySQL Shell Docker images and update README
1 parent fb356fd commit 3579094

File tree

5 files changed

+168
-17
lines changed

5 files changed

+168
-17
lines changed

.github/workflows/docker-build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build MySQL Shell Docker Images
2+
3+
# Add explicit permissions
4+
permissions:
5+
contents: read
6+
packages: write
7+
8+
on:
9+
push:
10+
branches: [ main ]
11+
paths:
12+
- docker/**
13+
- .github/workflows/docker-build.yml
14+
pull_request:
15+
branches: [ main ]
16+
paths:
17+
- docker/**
18+
- .github/workflows/docker-build.yml
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
include:
27+
- series: innovation
28+
version: 9.2
29+
extra_tag: innovation
30+
- series: lts
31+
version: 8.4
32+
extra_tag: lts
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Login to Docker Hub
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKER_USERNAME }}
44+
password: ${{ secrets.DOCKER_PASSWORD }}
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: ./docker/${{ matrix.series }}
50+
push: ${{ github.event_name != 'pull_request' }}
51+
tags: |
52+
snickerjp/docker-mysql-shell:${{ matrix.version }}
53+
snickerjp/docker-mysql-shell:${{ matrix.extra_tag }}
54+
${{ matrix.series == 'lts' && 'snickerjp/docker-mysql-shell:latest' || '' }}

README.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,64 @@
1-
# docker-mysql-shell
1+
# Docker MySQL Shell Images
22

33
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/314c46648b7a4b85a25edfeef95edad5)](https://app.codacy.com/gh/snickerjp/docker-mysql-shell?utm_source=github.com&utm_medium=referral&utm_content=snickerjp/docker-mysql-shell&utm_campaign=Badge_Grade_Settings)
44

5-
## spec
5+
This repository contains Dockerfiles for MySQL Shell in two different series:
6+
- Innovation Series (9.2.x) - Latest features [(Dockerfile)](docker/innovation/Dockerfile)
7+
- LTS Series (8.4.x) - Long Term Support [(Dockerfile)](docker/lts/Dockerfile)
68

7-
* Ubuntu
8-
* MySQL Shell
9+
Both images are based on Debian 12 (slim) for minimal image size.
10+
11+
## Available Tags
12+
13+
### Innovation Series [(Dockerfile)](docker/innovation/Dockerfile)
14+
- `snickerjp/docker-mysql-shell:9.2` - Innovation series with specific version
15+
- `snickerjp/docker-mysql-shell:innovation` - Latest Innovation series build
16+
17+
### LTS Series [(Dockerfile)](docker/lts/Dockerfile)
18+
- `snickerjp/docker-mysql-shell:8.4` - LTS series with specific version
19+
- `snickerjp/docker-mysql-shell:lts` - Latest LTS series build
20+
- `snickerjp/docker-mysql-shell:latest` - Same as LTS series
21+
22+
## Building the Images
23+
24+
### Innovation Series (9.2.x) [(Dockerfile)](docker/innovation/Dockerfile)
25+
```bash
26+
cd docker/innovation
27+
docker build -t snickerjp/docker-mysql-shell:9.2 .
28+
```
29+
30+
### LTS Series (8.4.x) [(Dockerfile)](docker/lts/Dockerfile)
31+
```bash
32+
cd docker/lts
33+
docker build -t snickerjp/docker-mysql-shell:8.4 .
34+
```
35+
36+
## Usage
37+
38+
Run MySQL Shell container:
39+
40+
```bash
41+
# Innovation Series
42+
docker run -it snickerjp/docker-mysql-shell:9.2
43+
# or
44+
docker run -it snickerjp/docker-mysql-shell:innovation
45+
46+
# LTS Series
47+
docker run -it snickerjp/docker-mysql-shell:8.4
48+
# or
49+
docker run -it snickerjp/docker-mysql-shell:lts
50+
# or
51+
docker run -it snickerjp/docker-mysql-shell:latest
52+
```
53+
54+
To connect to a MySQL Server:
55+
```bash
56+
# Innovation Series
57+
docker run -it snickerjp/docker-mysql-shell:9.2 --uri mysql://user:pass@host:port/schema
58+
# or using innovation tag
59+
docker run -it snickerjp/docker-mysql-shell:innovation --uri mysql://user:pass@host:port/schema
60+
61+
# LTS Series
62+
docker run -it snickerjp/docker-mysql-shell:8.4 --uri mysql://user:pass@host:port/schema
63+
# or using lts tag
64+
docker run -it snickerjp/docker-mysql-shell:lts --uri mysql://user:pass@host:port/schema

docker/Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

docker/innovation/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM debian:12-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG MYSQL_SHELL_VERSION=9.2.0
5+
6+
# Create a user for the container
7+
RUN useradd -ms /bin/bash mysqlshelluser
8+
9+
RUN apt-get update && apt-get install -y \
10+
wget \
11+
&& rm -rf /var/lib/apt/lists/* \
12+
&& wget https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
13+
&& apt-get update \
14+
&& apt-get install -y ./mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
15+
&& rm -f mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
16+
&& apt-get remove -y wget \
17+
&& apt-get autoremove -y \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Switch to the non-root user
21+
USER mysqlshelluser
22+
23+
# Add a healthcheck
24+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD mysqlsh --version || exit 1
25+
26+
ENTRYPOINT ["mysqlsh"]
27+
CMD ["--version"]

docker/lts/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM debian:12-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG MYSQL_SHELL_VERSION=8.4.4
5+
6+
# Create a user for the container
7+
RUN useradd -ms /bin/bash mysqlshelluser
8+
9+
RUN apt-get update && apt-get install -y \
10+
wget \
11+
&& rm -rf /var/lib/apt/lists/* \
12+
&& wget https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
13+
&& apt-get update \
14+
&& apt-get install -y ./mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
15+
&& rm -f mysql-shell_${MYSQL_SHELL_VERSION}-1debian12_amd64.deb \
16+
&& apt-get remove -y wget \
17+
&& apt-get autoremove -y \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Switch to the non-root user
21+
USER mysqlshelluser
22+
23+
# Add a healthcheck
24+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD mysqlsh --version || exit 1
25+
26+
ENTRYPOINT ["mysqlsh"]
27+
CMD ["--version"]

0 commit comments

Comments
 (0)