Docker Deployment
About 551 wordsAbout 2 min
Info
A solid tutorial site: Docker — From Getting Started to Practice
Local Deployment
Local deployment is meant to quickly provide a local API service.
Backend
env
Open a terminal in the
backenddirectory and create the environment file:touch .envCopy the initial environment configuration into the environment file:
cp .env.example .envUpdate configuration as needed in
backend/core/conf.pyand.envBuild the container
Open a terminal in the project root and run:
Warning
If the container will run locally, change
127.0.0.1in.envtohost.docker.internalfbadocker build -f Dockerfile -t fba_server_independent .celerydocker build --build-arg SERVER_TYPE=fba_celery_worker -t fba_celery_worker_independent .Start the container
Because the build does not include a database, make sure the required databases (PostgreSQL / MySQL, Redis) are installed and running locally.
fbadocker run -d -p 8001:8001 --name fba_server fba_server_independentcelerydocker run -d --name fba_celery_worker fba_celery_worker_independent
Frontend
Server Deployment
Warning
This guide uses HTTPS as an example
fba uses a free SSL certificate: httpsok-SSL. Certificates renew automatically — one command handles SSL auto-renewal, with support for nginx, wildcard certificates, Qiniu Cloud, Tencent Cloud, Alibaba Cloud, CDN, OSS, and LB (load balancing).
Backend
Pull the code onto the server
Pulling code onto a server is usually done via SSH (more secure). You can also use HTTPS — choose whichever approach you prefer.
env
Open a terminal in the
backenddirectory and create the environment file:touch .envGo to the
deploy/backend/docker-composedirectory and update the.env.serverfile as needed.Info
In the docker-compose scripts, the
.env.serverfile is mounted as the fba environment file. Changes you make locally are synced into the Docker container, so updating environment variables does not require a rebuild.Warning
If you are using a MySQL database, update part of
.env.serveras follows:# Database DATABASE_TYPE='mysql' DATABASE_HOST='fba_mysql' DATABASE_PORT=3306 DATABASE_USER='root' DATABASE_PASSWORD='123456'Update configuration as needed in
backend/core/conf.pyUpdate the docker-compose scripts
The
docker-compose.ymlscript includes comments — modify it as needed.Run the one-click start command
Open a terminal in the project root and run:
Warning
If you run into image pull issues while the command is running, please search for a solution yourself.
Default port mappingdocker compose up -d --buildCustom port mappingdocker compose --env-file deploy/backend/docker-compose/.env.docker up -d --buildWait for the command to finish
Frontend
Notes
Warning
Avoid frequently running docker compose up -d --build. Every run rebuilds containers and keeps local backups of the previous ones, which can quickly consume disk space.
15 scripts for automated Docker container management
Clean unused images:
docker image pruneClean unused containers:
docker container pruneClean all unused images, containers, networks, and build cache:
docker system prune
