Skip to content

Commit

Permalink
add mysql and docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
bbq-all-stars committed Jan 21, 2022
1 parent f7dc406 commit 269bbe0
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 3 deletions.
28 changes: 25 additions & 3 deletions problem1/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ networks:
ipam:
config:
- subnet: 10.0.0.0/16
back:
ipam:
config:
- subnet: 10.10.0.0/16

volumes:
socket:
Expand All @@ -16,11 +20,29 @@ volumes:

services:
app:
build: app/
container_name: minimal_sns_app
volumes:
- socket:/var/run/unicorn/
# NOTE: for ruby
# build: app/ruby
# volumes:
# - socket:/var/run/unicorn/
# NOTE: for go
build: app/go
ports:
- "1323:1323"
networks:
- front
- back
environment:
- "TZ=Asia/Tokyo"
db:
image: mysql:latest
container_name: db
networks:
- back
volumes:
- ./mysql/my.cnf:/etc/mysql/my.cnf
- ./mysql/conf.d/mysql.cnf:/etc/mysql/conf.d/mysql.cnf
- ./mysql/0_init.sql:/docker-entrypoint-initdb.d/0_init.sql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: app
20 changes: 20 additions & 0 deletions problem1/mysql/0_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE `users` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(64) DEFAULT '' NOT NULL,
PRIMARY KEY (`id`)
);
-- user1 user2
CREATE TABLE `friend_link` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user1_id` int(11) NOT NULL,
`user2_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
-- user1 user2 block
CREATE TABLE `block_list` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user1_id` int(11) NOT NULL,
`user2_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
29 changes: 29 additions & 0 deletions problem1/mysql/conf.d/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2015, 2021, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Client configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysql]
29 changes: 29 additions & 0 deletions problem1/mysql/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL

# Custom config should go here
!includedir /etc/mysql/conf.d/

0 comments on commit 269bbe0

Please sign in to comment.