-
-
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.
Merge pull request #13 from docksal/develop
Release 1.3.0
- Loading branch information
Showing
25 changed files
with
340 additions
and
1,031 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
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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
# Database Docker images for Docksal | ||
|
||
Docksal MySQL images are derived from the stock `mysql` images from Docker Hub. | ||
We include extra settings (see `default.cnf`) and make slight modifications to `docker-entrypoint.sh`. | ||
Docksal MySQL images are derived from the stock `mysql` images from Docker Hub with a few adjustments (see Features). | ||
|
||
We include and enable user defined overrides via a settings file. | ||
|
||
This image(s) is part of the [Docksal](http://docksal.io) image library. | ||
|
||
## Features | ||
|
||
- Better default settings (see `default.cnf`) | ||
- Ability to pass additional settings via a file mounted into the container | ||
- User defined MySQL settings are expected in `/var/www/.docksal/etc/mysql/my.cnf` in the container. | ||
- Running a startup script as root | ||
- Scripts should be placed in the `/docker-entrypoint.d/` folder | ||
- Docker heathcheck support | ||
|
||
## Versions | ||
|
||
- `mysql-5.5` | ||
- `mysql-5.6` | ||
- `mysql-5.7`, `latest` | ||
- `mysql-5.6`, `latest` | ||
- `mysql-5.7` | ||
- `mysql-8.0` |
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
FROM mysql:5.5.61 | ||
|
||
# Docksal settings | ||
# MySQL settings | ||
COPY default.cnf /etc/mysql/conf.d/10-default.cnf | ||
|
||
VOLUME /var/lib/mysql | ||
|
||
COPY docker-entrypoint.sh /entrypoint.sh | ||
# Add support for init script run under root user at startup | ||
# Scripts should be placed in the /docker-entrypoint.d/ folder | ||
COPY docker-entrypoint.d.sh /usr/local/bin/docker-entrypoint.d.sh | ||
RUN set -xe; \ | ||
sed -i '/\$(id -u)/ r /usr/local/bin/docker-entrypoint.d.sh' /usr/local/bin/docker-entrypoint.sh | ||
# Init scripts run under root | ||
COPY docker-entrypoint.d /docker-entrypoint.d | ||
COPY healthcheck.sh /opt/healthcheck.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
EXPOSE 3306 | ||
CMD ["mysqld"] | ||
# Fix PATH to include MySQL 5.5 binaries | ||
RUN echo 'PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts' >> /etc/profile | ||
|
||
# Health check script | ||
HEALTHCHECK --interval=5s --timeout=1s --retries=12 CMD ["/opt/healthcheck.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
-include env_make | ||
|
||
SHELL = /bin/bash | ||
VERSION ?= mysql-5.5 | ||
|
||
REPO = docksal/db | ||
NAME = docksal-db-$(VERSION) | ||
IMAGE = $(REPO):$(VERSION) | ||
NAME = docksal-db-${VERSION} | ||
MYSQL_ROOT_PASSWORD = root | ||
MYSQL_USER = user | ||
MYSQL_PASSWORD = user | ||
MYSQL_DATABASE = default | ||
ENV = -e MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) -e MYSQL_USER=$(MYSQL_USER) -e MYSQL_PASSWORD=$(MYSQL_PASSWORD) -e MYSQL_DATABASE=$(MYSQL_DATABASE) | ||
ENV = -e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} -e MYSQL_USER=${MYSQL_USER} -e MYSQL_PASSWORD=${MYSQL_PASSWORD} -e MYSQL_DATABASE=${MYSQL_DATABASE} | ||
|
||
.PHONY: build test push shell run start stop logs clean release | ||
.EXPORT_ALL_VARIABLES: | ||
|
||
.PHONY: build exec test push shell run start stop logs debug clean release | ||
|
||
build: | ||
docker build -t $(IMAGE) . | ||
fin docker build -t ${REPO}:${VERSION} . | ||
|
||
test: | ||
IMAGE=$(IMAGE) NAME=$(NAME) bats ../tests/test.bats | ||
IMAGE=${REPO}:${VERSION} bats ../tests/test.bats | ||
|
||
push: | ||
docker push $(IMAGE) | ||
fin docker push ${REPO}:${VERSION} | ||
|
||
exec: | ||
@fin docker exec ${NAME} ${CMD} | ||
|
||
exec-it: | ||
@fin docker exec -it ${NAME} ${CMD} | ||
|
||
shell: | ||
docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(IMAGE) /bin/bash | ||
@make exec-it -e CMD=sh | ||
|
||
run: | ||
docker run --rm --name $(NAME) -it $(PORTS) $(VOLUMES) $(ENV) $(IMAGE) | ||
fin docker run --rm --name ${NAME} -it ${PORTS} ${VOLUMES} ${ENV} ${REPO}:${VERSION} | ||
|
||
start: clean | ||
docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(IMAGE) | ||
|
||
exec: | ||
docker exec -it $(NAME) /bin/bash | ||
fin docker run -d --name ${NAME} ${PORTS} ${VOLUMES} ${ENV} ${REPO}:${VERSION} | ||
|
||
mysql-query: | ||
# Usage: make mysql-query QUERY='SHOW DATABASES;' | ||
docker exec $(NAME) bash -c "mysql --host=localhost --user=root --password=$(MYSQL_ROOT_PASSWORD) -e '$(QUERY)'" | ||
fin docker exec ${NAME} bash -c "mysql --host=localhost --user=root --password=${MYSQL_ROOT_PASSWORD} -e '${QUERY}'" | ||
|
||
stop: | ||
docker stop $(NAME) | ||
fin docker stop ${NAME} | ||
|
||
logs: | ||
docker logs $(NAME) | ||
fin docker logs ${NAME} | ||
|
||
clean: | ||
docker rm -f $(NAME) >/dev/null 2>&1 || true | ||
logs-follow: | ||
fin docker logs -f ${NAME} | ||
|
||
debug: build start logs-follow | ||
|
||
release: build push | ||
release: | ||
@../scripts/release.sh | ||
|
||
clean: | ||
fin docker rm -vf ${NAME} || true | ||
|
||
default: build |
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 @@ | ||
|
||
# Process init scripts run by root | ||
for f in /docker-entrypoint.d/*; do | ||
echo "Running init scripts in /docker-entrypoint.d/ as root..." | ||
process_init_file "$f" "${mysql[@]}" | ||
done | ||
|
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ "$(id -u)" = '0' ]]; then | ||
# Copy custom settings (if mounted) from /var/www/.docksal/etc/mysql/my.cnf and fix permissions | ||
project_config_file='/var/www/.docksal/etc/mysql/my.cnf' | ||
echo "Including custom configuration from ${project_config_file}" | ||
if [[ -f ${project_config_file} ]]; then | ||
cp -a ${project_config_file} /etc/mysql/conf.d/99-overrides.cnf | ||
chown -R root:root /etc/mysql/conf.d/* | ||
chmod -R 644 /etc/mysql/conf.d/* | ||
fi | ||
fi |
Oops, something went wrong.