[READ-ONLY] Mirror of https://github.com/andrioid/mysql-from-s3. MySQL server that seeds from S3 when run for the first time.
2.7 kB
53 lines
1# mysql-from-s3
2
3It's essentially "[mysql:5.6](https://registry.hub.docker.com/_/mysql/)" from the official builds on Docker Hub, with a twist. You can find an automated build on [Docker Hub](https://registry.hub.docker.com/u/andrioid/mysql-from-s3/).
4
5Note: This is pretty early and I'm still fighting with a few bugs. It's a work in progress.
6
7## Introduction
8
9
10
11MySQL server that will seed the database from a gzipped dump file on S3 when run for the first time. I use s3gof3r to stream the compressed dump file from S3.
12
13
14### MySQL 5.6 and small VPS machines
15According to a [bug](https://github.com/docker-library/mysql/issues/3) MySQL 5.6 is not intended to run on tiny boxes. I'm not content with that, so if the server detects that your memory is below 1GB it will load a secondary configuration that will do the following:
16
17- Lower the memory footprint as much as possible
18- Disable InnoDB
19- Disable Performance Metrics
20
21This enables me to run a database on [DigitalOcean](https://www.digitalocean.com/?refcode=eb735821ebb8)'s (referral link) 512MB droplets without adding swap.
22
23## Use Cases
24
25
26### Staging Server
27Some companies like to run staging on actual data, but doing it in production can cause problems. A backup-script runs daily on the production database and pushes a gzipped dump-file to S3.
28
29Then run mysql-from-s3 with Docker without mounting the /var/lib/mysql volume. That way, a fresh database is seeded from S3, every time you restart the server. It also helps making sure that your database backups are working.
30
31
32### Personal Blog
33I have a Drupal site and it's driving me crazy. I spend more time upgrading Drupal, than writing stuff on my site.
34
35If the host-machine dies, the worst case scenario is that I have to roll back to the latest backup. I can live with that.
36
37This requires mounting the /var/lib/mysql to a host-directory. That way, you can restart the container without losing data and re-initializing from S3.
38
39## Configuration
40
41- S3_BUCKET: Name of the S3 Bucket
42- S3_OBJ: Object name (with prefix)
43- AWS_ACCESS_KEY_ID: IAM key
44- AWS_SECRET_ACCESS_KEY=none: IAM secret (has to have S3 read access)
45- MYSQL_ROOT_PASSWORD
46
47You also have to add a volume for /var/lib/mysql if you don't want the container to seed every time you run it.
48
49If you have plans to use this as a personal DB. I strongly recommend that you automatically backup your database to S3.
50
51## Example
52
53``docker run -t -i -e AWS_ACCESS_KEY_ID=editme -e AWS_SECRET_ACCESS_KEY=editme -e S3_BUCKET=editme -e S3_OBJ=backup/editme.sql.gz -e MYSQL_ROOT_PASSWORD=editme -p 3306:3306 andrioid/mysql-from-s3``