Containerization has many advantages. One advantage among these is getting up and running quickly with a production ready datasource, which has predefined data in it. This way we can reuse the shared application data state in local development environments easily. The snippets above serves as a baseline to achieve this goal. Further information is available on my blog
Last active
April 5, 2019 10:15
-
-
Save entrofi/26f97f3a186d8f32a5989956feb36cf7 to your computer and use it in GitHub Desktop.
Creating a Customized Mysql Docker Image Supported by Initialization Scripts
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
CREATE TABLE card ( | |
id bigint(20) NOT NULL, | |
back varchar(255) NOT NULL, | |
front varchar(255) NOT NULL, | |
hint varchar(255) DEFAULT NULL, | |
PRIMARY KEY (id) | |
); |
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
FROM mysql:8.0 | |
LABEL description="My Custom Mysql Docker Image" | |
# Add a database | |
ENV MYSQL_DATABASE CARDS | |
#Check out docker entry point for further configuration : | |
# https://github.com/docker-library/mysql | |
COPY ./init-scripts/ /docker-entrypoint-initdb.d/ |
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
INSERT INTO card (id, front, back, hint) values (1, 'Front 1', 'Back 1', 'Hint 1'); | |
INSERT INTO card (id, front, back, hint) values (2, 'Front 2', 'Back 2', 'Hint 2'); | |
INSERT INTO card (id, front, back, hint) values (3, 'Front 3', 'Back 3', 'Hint 3'); | |
INSERT INTO card (id, front, back, hint) values (4, 'Front 4', 'Back 4', 'Hint 4'); | |
INSERT INTO card (id, front, back, hint) values (5, 'Front 5', 'Back 5', 'Hint 5'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment