diff --git a/db/dockerfile b/db/dockerfile new file mode 100644 index 0000000..57c7515 --- /dev/null +++ b/db/dockerfile @@ -0,0 +1,2 @@ +from mysql:8 +add init.sql /docker-entrypoint-initdb.d \ No newline at end of file diff --git a/db/init.sql b/db/init.sql new file mode 100644 index 0000000..9cd4b60 --- /dev/null +++ b/db/init.sql @@ -0,0 +1,9 @@ +create database if not exists tqna; + +create table if not exists tqna.questions ( + `__id` integer not null auto_increment primary key, + `channel` text, + `asker` text, + `question` text, + `answered` boolean +); \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 2cc127a..749f60c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -15,6 +15,8 @@ services: disable: true volumes: - "./api:/app" + links: + - "db" stdin_open: true tty: true @@ -34,3 +36,27 @@ services: stdin_open: true tty: true + + db: + build: + context: "./database" + docker: "dockerfile" + restart: "unless-stopped" + volumes: + - "./data:/var/lib/mysql" + environment: + MYSQL_ROOT_PASSWORD: "root" + healthcheck: + test: "mysqladmin ping -h localhost" + timeout: 30s + retries: 5 + start_period: 60s + + adminer: + image: adminer + ports: + - "8081:8080" + depends_on: + - "db" + links: + - "db" \ No newline at end of file