Skip to content

Commit

Permalink
Merge branch 'release/10.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pozgo committed Feb 7, 2018
2 parents 57b4f37 + f38d6d1 commit 6d66fcf
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 48 deletions.
23 changes: 9 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
FROM centos:7
MAINTAINER Marcin Ryzycki [email protected], Przemyslaw Ozgo [email protected]
FROM alpine:latest

# Set TERM env to avoid mysql client error message "TERM environment variable not set" when running from inside the container
ENV TERM=xterm \
MARIADB_VERSION=10.2

# Copy only files required for the following RUN commands (leverage Docker caching)
COPY container-files /
MARIADB_VERSION=10.1

RUN \
sed -i "s#MARIADB_VERSION#"${MARIADB_VERSION}"#g" /etc/yum.repos.d/mariadb.repo && \
yum update -y && \
yum install -y epel-release && \
yum install -y MariaDB-server hostname net-tools pwgen && \
yum clean all && \
rm -rf /var/lib/mysql/* && \

`# Install mysqltuner.pl` \
apk --no-cache add mariadb~${MARIADB_VERSION} mariadb-client net-tools pwgen curl bash; \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*; \
rm -rf /var/lib/mysql/* /etc/mysql/; \
curl -sSL http://mysqltuner.pl/ -o mysqltuner.pl

# Copy only files required for the following RUN commands (leverage Docker caching)
COPY container-files /

EXPOSE 3306

CMD ["/run.sh"]
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# MariaDB 10 Docker Image (Centos7)
# MariaDB 10 Docker Image (Alpine ~100Mb)
[![CircleCI Build Status](https://img.shields.io/circleci/project/million12/docker-mariadb/master.svg)](https://circleci.com/gh/million12/docker-mariadb/tree/master)
[![GitHub Open Issues](https://img.shields.io/github/issues/million12/docker-mariadb.svg)](https://github.com/million12/docker-mariadb/issues)
[![GitHub Stars](https://img.shields.io/github/stars/million12/docker-mariadb.svg)](https://github.com/million12/docker-mariadb)
[![GitHub Forks](https://img.shields.io/github/forks/million12/docker-mariadb.svg)](https://github.com/million12/docker-mariadb)
[![Stars on Docker Hub](https://img.shields.io/docker/stars/million12/mariadb.svg)](https://hub.docker.com/r/million12/mariadb)
[![Pulls on Docker Hub](https://img.shields.io/docker/pulls/million12/mariadb.svg)](https://hub.docker.com/r/million12/mariadb)
[![](https://images.microbadger.com/badges/version/million12/mariadb.svg)](http://microbadger.com/images/million12/mariadb)
[![](https://images.microbadger.com/badges/license/million12/mariadb.svg)](http://microbadger.com/images/million12/mariadb)
[![](https://images.microbadger.com/badges/image/million12/mariadb.svg)](http://microbadger.com/images/million12/mariadb)
[![GitHub Open Issues](https://img.shields.io/github/issues/million12/docker-mariadb.svg)](https://github.com/million12/docker-mariadb/issues)
[![Stars](https://img.shields.io/github/stars/million12/docker-mariadb.svg?style=social&label=Stars)]()
[![Fork](https://img.shields.io/github/forks/million12/docker-mariadb.svg?style=social&label=Fork)]()
[![](https://img.shields.io/github/release/million12/docker-mariadb.svg)](http://microbadger.com/images/million12/mariadb)
[![Docker build](http://dockeri.co/image/million12/mariadb)](https://hub.docker.com/r/million12/mariadb/)

Felling like supporting me in my projects use donate button. Thank You!
[![](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.me/POzgo)

This is a MariaDB 10 Docker [million12/mariadb](https://registry.hub.docker.com/u/million12/mariadb/) image. Built on top of official [centos:7](https://registry.hub.docker.com/_/centos/) image. Inspired by [Tutum](https://github.com/tutumcloud)'s [tutum/mariadb](https://github.com/tutumcloud/tutum-docker-mariadb) image.

This is a MariaDB 10 in a Docker [million12/mariadb](https://registry.hub.docker.com/u/million12/mariadb/).

**IMPORTANT: Migarted to Alpine Linux which shrinked the image from 1024M to ~120Mb**

Note: be aware that, by default in this container, MariaDB is configured to use ~1GB memory (innodb_buffer_pool_size in [tuning.cnf](container-files/etc/my.cnf.d/tuning.cnf)). If you try to run it on node with less memory, it will fail.

Expand All @@ -19,17 +21,26 @@ Please use tags on Docker Hub for different versions.
## Usage

Run the image as daemon and bind it to port 3306:
`docker run -d -p 3306:3306 million12/mariadb`

```bash
docker run -d \
-p 3306:3306 \
million12/mariadb
```

Run the image as daemon and specify MariaDB version 10.2:
`docker run -d million12/mariadb:10.2`

```bash
docker run -d \
million12/mariadb:10.1
```

The first time that you run your container, a new user admin with all privileges will be created in MariaDB with a random password. To get the password, check the logs of the container by running:
`docker logs <CONTAINER_ID>`

You will see an output like the following:

```
```bash
========================================================================
You can now connect to this MariaDB Server using:

Expand All @@ -44,14 +55,19 @@ In this case, `CoFlnc3ZBS58` is the password assigned to the `admin` user.
### Custom Password for user admin
If you want to use a preset password instead of a random generated one, you can set the environment variable MARIADB_PASS to your specific password when running the container:

`docker run -d -p 3306:3306 -e MARIADB_PASS="mypass" million12/mariadb`
```bash
docker run -d \
-p 3306:3306 \
-e MARIADB_PASS="mypass" \
million12/mariadb
```

### Data volumes

MariaDB stores data in `/var/lib/mysql` location. Mount a volume
to that location - below is an example with docker-compose how to do that:
to that location - below is an example with `docker-compose` how to do that:

```
```yaml
version: '2'

volumes:
Expand All @@ -64,12 +80,9 @@ services:
- dbdata:/var/lib/mysql
```
---
## Authors
Author: Marcin Ryzycki (<[email protected]>)
Author: Przemyslaw Ozgo (<[email protected]>)

---

**Sponsored by [Prototype Brewery](http://prototypebrewery.io/)** - the new prototyping tool for building highly-interactive prototypes of your website or web app. Built on top of [Neos CMS](https://www.neos.io/) and [Zurb Foundation](http://foundation.zurb.com/) framework.
14 changes: 11 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ machine:

dependencies:
override:
- docker build -t million12/mariadb .
- RELEASE=$(grep "MARIADB_VERSION=" Dockerfile | sed 's|^.*=||g' |awk '{print $1}'); docker build -t million12/mariadb:$RELEASE .
- docker build -t million12/mariadb:latest .

test:
override:
- docker run -d -p 13306:3306 -e MARIADB_PASS="mypass" --name db million12/mariadb
- docker run -d -p 13306:3306 -e MARIADB_PASS="mypass" --name db million12/mariadb:$RELEASE
- docker logs -f db > ${CIRCLE_ARTIFACTS}/docker-db.log:
background: true
# Wait till DB is fully bootstrapped
- while true; do if grep "ready for connections" ${CIRCLE_ARTIFACTS}/docker-db.log; then break; else sleep 1; fi done

- mysqladmin -uadmin -pmypass -h127.0.0.1 -P13306 ping
- mysql -uadmin -pmypass -h127.0.0.1 -P13306 -e "show databases"

deployment:
production:
branch: master
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
- RELEASE=$(grep "MARIADB_VERSION=" Dockerfile | sed 's|^.*=||g' |awk '{print $1}'); docker push million12/mariadb:$RELEASE
- docker push million12/mariadb:latest
16 changes: 16 additions & 0 deletions container-files/etc/mysql/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!include /etc/my.cnf.d/charset.cnf
!include /etc/my.cnf.d/engine.cnf
!include /etc/my.cnf.d/logging.cnf
!include /etc/my.cnf.d/networking.cnf
!include /etc/my.cnf.d/security.cnf
!include /etc/my.cnf.d/slowlog.cnf
!include /etc/my.cnf.d/tuning.cnf
7 changes: 0 additions & 7 deletions container-files/etc/yum.repos.d/mariadb.repo

This file was deleted.

5 changes: 1 addition & 4 deletions container-files/mariadb-functions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh

#!/bin/bash

#########################################################
# Check in the loop (every 1s) if the database backend
Expand All @@ -20,7 +19,6 @@ function wait_for_db() {
set -e
}


#########################################################
# Check in the loop (every 1s) if the database backend
# service is already available for connections.
Expand All @@ -35,7 +33,6 @@ function terminate_db() {
done
}


#########################################################
# Cals `mysql_install_db` if empty volume is detected.
# Globals:
Expand Down

0 comments on commit 6d66fcf

Please sign in to comment.