-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pagemachine/init
Initialize setup
- Loading branch information
Showing
6 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: '0 7 * * *' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./test | ||
|
||
env: | ||
BUILD_IMAGE_TAG: ${{ github.run_id }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build & Start | ||
run: docker compose up --detach --wait mysql | ||
|
||
- name: Dump & Diff | ||
run: > | ||
docker compose exec mysql | ||
mysqldump --compact --skip-extended-insert db | ||
| | ||
diff --unified --color expected.sql - | ||
- name: Cleanup | ||
if: ${{ always() }} | ||
run: docker compose down --rmi=all --volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG MYSQL_IMAGE_VERSION | ||
FROM mysql:${MYSQL_IMAGE_VERSION} as base | ||
|
||
ARG MYSQL_DATABASE | ||
ENV MYSQL_DATABASE=${MYSQL_DATABASE} | ||
ARG MYSQL_USER | ||
ENV MYSQL_USER=${MYSQL_USER} | ||
ARG MYSQL_PASSWORD | ||
ENV MYSQL_PASSWORD=${MYSQL_PASSWORD} | ||
ARG MYSQL_ROOT_PASSWORD | ||
ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} | ||
|
||
FROM base as init | ||
|
||
COPY --from=data * /docker-entrypoint-initdb.d | ||
|
||
RUN mkdir --parents /var/lib/mysql-data \ | ||
&& chown mysql:mysql /var/lib/mysql-data | ||
|
||
RUN sed --in-place 's/exec "$@"//' /usr/local/bin/docker-entrypoint.sh | ||
|
||
RUN docker-entrypoint.sh --datadir /var/lib/mysql-data | ||
|
||
FROM base | ||
|
||
COPY --from=init /var/lib/mysql-data /var/lib/mysql | ||
|
||
RUN chown mysql:mysql /var/lib/mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE test_table ( | ||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
title VARCHAR(255) | ||
); | ||
|
||
INSERT INTO test_table VALUES (1, "foo"); | ||
INSERT INTO test_table VALUES (2, "bar"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
services: | ||
mysql: | ||
build: | ||
context: .. | ||
additional_contexts: | ||
data: ./data | ||
args: | ||
MYSQL_IMAGE_VERSION: 8.1.0 | ||
MYSQL_DATABASE: db | ||
MYSQL_USER: test | ||
MYSQL_PASSWORD: test | ||
MYSQL_ROOT_PASSWORD: root | ||
environment: | ||
MYSQL_PWD: root | ||
healthcheck: | ||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 10 | ||
image: docker-mysql-data:${BUILD_IMAGE_TAG:?} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!50503 SET character_set_client = utf8mb4 */; | ||
CREATE TABLE `test_table` ( | ||
`id` int NOT NULL AUTO_INCREMENT, | ||
`title` varchar(255) DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
INSERT INTO `test_table` VALUES (1,'foo'); | ||
INSERT INTO `test_table` VALUES (2,'bar'); |