Skip to content

Commit

Permalink
Improve docker compose settings and add mysql as dependency (#4)
Browse files Browse the repository at this point in the history
Move docker-compose.yml to the root path.


From now on, use `docker compose up` will bring up everything in this
project.

To bring up api-server, run `docker compose up api-server`, this also
boots the dependencies - mongodb, mysqldb.
Ctrl+C will only stop api-server. mongo and mysql will remain. To stop
all, run `docker compose down`.
  • Loading branch information
kun98-liu authored Dec 8, 2024
1 parent 73ccd31 commit db68665
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 17 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# footbook
# What's this
SNS web application developed for learning


# How to run
```sh
# to run everything in this project
docker compose up

# to run specific component of the project with necessary dependency
docker compose up api-server
docker compose up frontend
```



# How to contribute
**ATTENTION: Please do not directly push any branch or commit to this repo.**

Expand All @@ -17,4 +29,10 @@ cd ./footbook

git remote add upstream [email protected]:kunlulukun/footbook.git
git remote set-url --push upstream NO-PUSH


# To keep update with latest master branch
git fetch --all
git checkout master
git merge upstream/master
```
2 changes: 1 addition & 1 deletion api-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ As this is only meant to run locally, dependencies like database have to be runn

The docker-compose.yml file should define all necessary containers and the api-server in it.

**so, the easiest way of booting this app is to run `docker compose up --build` under `/api-server` directory .**
**so, the easiest way of booting this app is to run `docker compose up api-server` under `/footbook` directory .**

Access http://0.0.0.0:8000/swagger for API definitions

Expand Down
5 changes: 5 additions & 0 deletions api-server/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

class Config:
MONGO_URI = os.getenv("MONGO_URI")
MYSQL_HOST = os.getenv("MYSQL_HOST")
MYSQL_PORT = os.getenv("MYSQL_PORT")
MYSQL_USER = os.getenv("MYSQL_USER")
MYSQL_PWD = os.getenv("MYSQL_PWD")
MYSQL_DB = os.getenv("MYSQL_DB")
14 changes: 0 additions & 14 deletions api-server/docker-compose.yml

This file was deleted.

37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.8'
services:
api-server:
build: api-server
ports:
- "8000:8000"
environment:
- MONGO_URI=mongodb://localhost:27017
- MYSQL_HOST=localhost
- MYSQL_PORT=3306
- MYSQL_USER=kunlulukun
- MYSQL_PWD=1016
- MYSQL_DB=footbook
depends_on:
- mongo
- mysql
frontend:
build: frontend
ports:
- "3000:80"
depends_on:
- api-server
mongo:
image: mongo
ports:
- "27017:27017"
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_DATABASE: "footbook"
MYSQL_USER: "kunlulukun"
MYSQL_PASSWORD: "1016"
volumes:
- ./mysql:/docker-entrypoint-initdb.d
ports:
- "3306:3306"
5 changes: 4 additions & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ You can access to the webpage on localhost:3000

### Option 2. docker compose up

TBD
```sh
# Run the following under /footbook
docker compose up frontend
```
5 changes: 5 additions & 0 deletions mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE IF NOT EXISTS test (
id CHAR(36),
name VARCHAR(100),
email VARCHAR(100)
);

0 comments on commit db68665

Please sign in to comment.