Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URL=mysql://admin:admin@db:3306/fastapi-admin
REDIS_URL=redis://redis:6379/0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this file is not needed (look its ignored in gitignore)

i would create .sample.env file with given default values 🤔

10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM jfloff/alpine-python
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN mkdir -p /fastapi-admin
WORKDIR /fastapi-admin
COPY pyproject.toml poetry.lock /fastapi-admin/
RUN pip3 install poetry
ENV POETRY_VIRTUALENVS_CREATE false
WORKDIR /tmp
ADD pyproject.toml .
ADD poetry.lock .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple oneline copy is sufficient (adds not needed)

COPY pyproject.toml poetry.lock ./

RUN poetry install --no-root

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove ENV POETRY_VIRTUALENVS_CREATE false
and simply do:

...
RUN poetry config virtualenvs.create false
RUN poetry install --no-root

also we can add ENV PYTHONUNBUFFERED 1

COPY . /fastapi-admin
RUN poetry install
RUN make compile
WORKDIR /fastapi-admin
11 changes: 2 additions & 9 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,8 @@
## 本地运行示例

1. 克隆仓库。
2. 创建 `.env` 文件。

```dotenv
DATABASE_URL=mysql://root:123456@127.0.0.1:3306/fastapi-admin
REDIS_URL=redis://localhost:6379/0
```

3. 运行 `docker-compose up -d --build`。
4. 访问 <http://localhost:8000/admin/init> 创建第一个管理员。
2. 运行 `docker-compose up -d --build`。
3. 访问 <http://localhost:8000/admin/init> 创建第一个管理员。

## 文档

Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@ Or pro version online demo [here](https://fastapi-admin-pro.long2ice.io/admin/lo
## Run examples in local

1. Clone repo.
2. Create `.env` file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then in readme we just inform

2. Copy sample env file and set your own environment variables
cp .sample.env .env


```dotenv
DATABASE_URL=mysql://root:123456@127.0.0.1:3306/fastapi-admin
REDIS_URL=redis://localhost:6379/0
```

3. Run `docker-compose up -d --build`.
4. Visit <http://localhost:8000/admin/init> to create first admin.
2. Run `docker-compose up -d --build`.
3. Visit <http://localhost:8000/admin/init> to create first admin.

## Documentation

Expand Down
30 changes: 28 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ services:
build: .
restart: always
env_file: .env
network_mode: host
image: fastapi-admin
command: uvicorn examples.main:app_ --port 8000 --host 0.0.0.0
command: bash -c "pybabel compile -d fastapi_admin/locales && uvicorn examples.main:app_ --port 8000 --host 0.0.0.0 --reload"
depends_on:
- db
- redis
volumes:
- .:/fastapi-admin
ports:
- 8000:8000

db:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in db instead of environment section:

  env_file: ./.env

suggestion:
i am wondering about creating additional docker-compose.dev.yaml file with db/redis service configuration 🤔

image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: fastapi-admin
MYSQL_USER: admin
MYSQL_PASSWORD: admin

redis:
image: 'redis:6.2.5-alpine'
volumes:
- redis_data:/data

volumes:
db_data:
redis_data: