Skip to content

Commit

Permalink
Merge pull request #166 from fortrabbit/fix/revert-mysql-workaround
Browse files Browse the repository at this point in the history
Revert mysql client issues workaround
  • Loading branch information
erinbit authored Apr 5, 2023
2 parents e8aa3bc + 9392709 commit b8a9ada
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 39 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ jobs:
matrix:
craft_image_tag: ['7.4', '8.0', '8.1']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Slugify branch/tag name
- name: Slugify branch name
shell: bash
run: echo "##[set-output name=slug;]$(echo $GITHUB_REF | sed -E 's/refs\/(heads|tags)\///g' | iconv -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)"
id: branch_slug
# Usage: ${{ steps.branch_slug.outputs.slug }}
run: echo "branch_slug=$(echo $GITHUB_REF | sed -E 's/refs\/(heads|tags)\///g' | iconv -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)" >> $GITHUB_ENV
# Usage: ${{ env.branch_slug }}

- name: Build docker image
working-directory: ./docker
run: |
docker build \
--build-arg CRAFT_IMAGE_TAG="${{ matrix.craft_image_tag }}" \
--tag $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }} \
--tag $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} \
--tag $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }} \
--tag $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ env.branch_slug }} \
--tag $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ env.branch_slug }} \
.
# Only publish main image (:8.0) on tag push matching "1.0.5" format
Expand All @@ -56,12 +55,12 @@ jobs:
- name: Publish dev image
if: steps.check-tag.outputs.match != 'true'
run: |
docker push $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }}
docker push $DOCKER_REGISTRY_IMAGE_DEV:${{ matrix.craft_image_tag }}_${{ env.branch_slug }}
# Main image will contain only builds from semantic tags
# ghcr.io/fortrabbit/craft-copy:8.0 - removed push to not break old installs of craft-copy that depend on old version of the image
# ghcr.io/fortrabbit/craft-copy:8.0_1.2.3
- name: Publish main image
if: steps.check-tag.outputs.match == 'true'
run: |
docker push $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ steps.branch_slug.outputs.slug }}
docker push $DOCKER_REGISTRY_IMAGE:${{ matrix.craft_image_tag }}_${{ env.branch_slug }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.3.2 - 2023-04-05
- Revert mysql command line tweaks

## 2.3.1 - 2023-04-03
- More tweaks on the mysql command line options

Expand Down
2 changes: 1 addition & 1 deletion bin/craft-copy-import-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
'{MYSQL_DATABASE}' => getenv('MYSQL_DATABASE'),
];

$cmd = 'mysql --defaults-extra-file={EXTRA_FILE} --ssl-mode=DISABLED --force {MYSQL_DATABASE} < {FILE} && echo 1';
$cmd = 'mysql --defaults-extra-file={EXTRA_FILE} --force {MYSQL_DATABASE} < {FILE} && echo 1';
$cmd = str_replace(array_keys($tokens), array_values($tokens), $cmd);

$process = \Symfony\Component\Process\Process::fromShellCommandline($cmd);
Expand Down
28 changes: 0 additions & 28 deletions src/Services/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public function import(?string $file = null): string
{
$file = $this->prepareFile($file);

$this->alterCraftDefaultRestoreCommand($file);

$this->db->restore($file);

return $file;
Expand Down Expand Up @@ -89,33 +87,7 @@ protected function alterCraftDefaultBackupCommand(string $file): void
$backupCommand
);

// Disable single-transaction for now
$backupCommand = str_replace(
' --single-transaction',
'',
$backupCommand
);

// Disable ssl-mode for now
$backupCommand = str_replace(
'--no-tablespaces',
'--no-tablespaces --ssl-mode=DISABLED',
$backupCommand
);

Craft::$app->getConfig()->getGeneral()->backupCommand = $backupCommand;
}

protected function alterCraftDefaultRestoreCommand(): void
{
// Determine the command that should be executed
$restoreCommand = $this->db->getSchema()->getDefaultRestoreCommand();

Craft::$app->getConfig()->getGeneral()->restoreCommand = str_replace(
'.cnf"',
'.cnf" --ssl-mode=DISABLED',
$restoreCommand
);

}
}

0 comments on commit b8a9ada

Please sign in to comment.