Commit 756cad6d authored by Yankova, Liliya (UG - Computer Science)'s avatar Yankova, Liliya (UG - Computer Science)
Browse files

Added sql script for creating the user table on docker compose

parent 1445714a
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
\ No newline at end of file
......@@ -7,8 +7,9 @@ docker ps -> check running containers
docker ps -a -> check all containers
Go into the main folder of this project
Execute - docker-compose up -d --build (This calls the docker-compose.yaml file and starts the containers.
The build option is for the Dockerfile - it enables the mysqli extension for the database);
docker-compose down -v (stops the running containers and effectively deletes the database volumes)
docker-compose build --no-cache (builds fresh images)
docker-compose up -d (executes the docker-compose.yaml file)
To check if the containers are running - docker ps
......@@ -17,7 +18,7 @@ Visit -> http://localhost:8000
To stop the containers - docker-compose down
For user service database:
mysql -u root -padvancedroot -h127.0.0.1 -P9906 -> root user
mysql -u root -puserRoot -h127.0.0.1 -P9906 -> root user
mysql -u service_user -pservice_user -h127.0.0.1 -P9906 -> service_user
For recipe service database:
......
......@@ -2,14 +2,15 @@ version: '3'
services:
userdb:
build: ./sql
image: mysql:8.0
container_name: user_db
volumes:
- dbdata:/var/lib/mysql
- dbdata:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: advancedroot
MYSQL_ROOT_PASSWORD: userRoot
MYSQL_DATABASE: userdb
MYSQL_USER: service_user
MYSQL_PASSWORD: service_user
......@@ -18,7 +19,7 @@ services:
expose:
- "9906"
web:
build: .
build: ./php
image: php:7.2.2-apache
container_name: php_web
depends_on:
......@@ -30,23 +31,5 @@ services:
stdin_open: true
tty: true
recipedb:
image: mysql:8.0
container_name: recipe_db
volumes:
- recipedata:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: reciperoot
MYSQL_DATABASE: recipedb
MYSQL_USER: recipe_user
MYSQL_PASSWORD: recipe_user
ports:
- "9907:3306"
expose:
- "9907"
volumes:
dbdata:
recipedata:
\ No newline at end of file
dbdata:
\ No newline at end of file
FROM php:7.2.2-apache
RUN docker-php-ext-install mysqli
\ No newline at end of file
FROM mysql:8.0
ENV MYSQL_DATABASE=userdb \
MYSQL_ROOT_PASSWORD=userRoot
COPY ./create_user.sql /docker-entrypoint-initdb.d/
\ No newline at end of file
use userdb;
go
create table user (
ID int(11) unique not null auto_increment,
username varchar(50) unique not null,
forename varchar(50) not null,
surname varchar(50) not null,
password varchar(60) not null,
email varchar(50) not null,
created_at datetime default current_timestamp,
primary key (ID)
);
go
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment