-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automtically install MySql in devcontainer for use by existing Go uni…
…t tests. TESTED by building the devcontainer, following setup instructions from README and finally running `make test`.
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 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,7 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:bullseye | ||
|
||
# Install MySql for Go backend unit tests. The tests expect MySql to be | ||
# installed directly in the development environment rather than in another | ||
# docker continer such as the dev database used for manual testing. | ||
COPY install-mysql.sh . | ||
RUN chmod +x ./install-mysql.sh && ./install-mysql.sh |
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,31 @@ | ||
# Original: https://gist.github.com/soubrunorocha/ec30b7704d737a1797b0281e97967834 | ||
|
||
# Fail if any line fails and return an error so that building this Dockerfile | ||
# will not swallow the script's errors. | ||
set -e | ||
|
||
#set the root password | ||
DEFAULTPASS="" | ||
|
||
#set some config to avoid prompting | ||
sudo debconf-set-selections <<EOF | ||
mysql-community-server mysql-community-server/root-pass password $DEFAULTPASS | ||
mysql-community-server mysql-community-server/re-root-pass password $DEFAULTPASS | ||
EOF | ||
|
||
#get the mysql repository via wget | ||
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb | ||
|
||
#set debian frontend to not prompt | ||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
#config the package | ||
sudo -E dpkg -i mysql-apt-config_0.8.29-1_all.deb | ||
|
||
#update apt to get mysql repository | ||
sudo apt update | ||
|
||
#install mysql according to previous config | ||
sudo -E apt install mysql-server mysql-client --assume-yes --force-yes | ||
|
||
rm mysql-apt-config_0.8.29-1_all.deb |