Installing (Docker) - aelassas/bookcars GitHub Wiki
BookCars can run in a Docker container on Linux and Docker Desktop for Windows or Mac.
This section describes how to build BookCars Docker image and run it in a Docker container.
- Clone BookCars repo:
git clone https://github.com/aelassas/bookcars.git
- Create
./backend/.env.docker
file with the following content:
# General
NODE_ENV=production
# Backend server
BC_PORT=4002
BC_HTTPS=false
BC_PRIVATE_KEY=/etc/ssl/bookcars.key
BC_CERTIFICATE=/etc/ssl/bookcars.crt
# MongoDB
BC_DB_URI="mongodb://admin:admin@mongo:27017/bookcars?authSource=admin&appName=bookcars"
BC_DB_SSL=false
BC_DB_SSL_CERT=/etc/ssl/bookcars.crt
BC_DB_SSL_CA=/etc/ssl/bookcars.ca.pem
BC_DB_DEBUG=false
# Auth
BC_COOKIE_SECRET=COOKIE_SECRET
BC_AUTH_COOKIE_DOMAIN=localhost
BC_ADMIN_HOST=http://localhost:3001/
BC_FRONTEND_HOST=http://localhost:8080/
BC_JWT_SECRET=JWT_SECRET
BC_JWT_EXPIRE_AT=86400
BC_TOKEN_EXPIRE_AT=86400
# Email (SMTP)
BC_SMTP_HOST=smtp.sendgrid.net
BC_SMTP_PORT=587
BC_SMTP_USER=apikey
BC_SMTP_PASS="PASSWORD"
BC_SMTP_FROM=[email protected]
# CDN (File storage)
BC_CDN_ROOT=/var/www/cdn
BC_CDN_USERS=/var/www/cdn/bookcars/users
BC_CDN_TEMP_USERS=/var/www/cdn/bookcars/temp/users
BC_CDN_CARS=/var/www/cdn/bookcars/cars
BC_CDN_TEMP_CARS=/var/www/cdn/bookcars/temp/cars
BC_CDN_LOCATIONS=/var/www/cdn/bookcars/locations
BC_CDN_TEMP_LOCATIONS=/var/www/cdn/bookcars/temp/locations
BC_CDN_CONTRACTS=/var/www/cdn/bookcars/contracts
BC_CDN_TEMP_CONTRACTS=/var/www/cdn/bookcars/temp/contracts
BC_CDN_LICENSES=/var/www/cdn/bookcars/licenses
BC_CDN_TEMP_LICENSES=/var/www/cdn/bookcars/temp/licenses
# Localization
BC_DEFAULT_LANGUAGE=en
# Business Rules
BC_MINIMUM_AGE=21
# Expo
BC_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN
# Stripe
BC_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
BC_STRIPE_SESSION_EXPIRE_AT=82800
# PayPal
BC_PAYPAL_SANDBOX=true
BC_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
BC_PAYPAL_CLIENT_SECRET=PAYPAL_CLIENT_SECRET
# Admin
BC_ADMIN_EMAIL=[email protected]
# Google reCAPTCHA
BC_RECAPTCHA_SECRET=RECAPTCHA_SECRET
# Misc
BC_WEBSITE_NAME=BookCars
BC_TIMEZONE=UTC # Timezone for cenverting dates from UTC to local time (used in emails sent from backend). TZ identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# IPInfo (Geo lookup)
BC_IPINFO_API_KEY=IPINFO_API_KEY # Required for more than 1000 requests/day
BC_IPINFO_DEFAULT_COUNTRY=US
# Language cleanup job
BC_BATCH_SIZE=1000 # Number of documents to process per batch when deleting obsolete language values
# Sentry (Error monitoring & performance tracing)
BC_ENABLE_SENTRY=false # Set to true to enable Sentry
BC_SENTRY_DSN_BACKEND=https://[email protected]/your_project_id # Your backend DSN (keep this secret)
BC_SENTRY_TRACES_SAMPLE_RATE=1.0 # Tracing sample rate: 1.0 = 100%, 0.1 = 10%, 0 = disabled
Set the following options:
BC_DB_URI=mongodb://admin:admin@mongo:27017/bookcars?authSource=admin&appName=bookcars
BC_COOKIE_SECRET=COOKIE_SECRET
BC_AUTH_COOKIE_DOMAIN=localhost
BC_JWT_SECRET=JWT_SECRET
BC_SMTP_HOST=smtp.sendgrid.net
BC_SMTP_PORT=587
BC_SMTP_USER=apikey
BC_SMTP_PASS=PASSWORD
BC_SMTP_FROM=[email protected]
BC_ADMIN_HOST=http://localhost:3001/
BC_FRONTEND_HOST=http://localhost/
BC_RECAPTCHA_SECRET=RECAPTCHA_SECRET
If you want to use MongoDB Atlas, put you MongoDB Atlas URI in BC_DB_URI
otherwise replace the second admin
in BC_DB_URI
with your MongoDB password. Replace JWT_SECRET
with a secret token. Finally, set the SMTP options. SMTP options are necessary for sign up. You can use sendgrid or any other transactional email provider.
If you choose sendgrid, create an account on sendgrid.com, login and go to the dashboard. On the left panel, click on Email API, then on Integration Guide. Then, choose SMTP Relay and follow the steps. You will be prompted to create an API Key. Once you create the API Key and verify the smtp relay, copy the API key in BC_SMTP_PASS
in ./backend/.env. Sendgrid's free plan allows to send up to 100 emails/day. If you need to send more than 100 emails/day, switch to a paid plan or choose another transactional email provider.
COOKIE_SECRET
and JWT_SECRET
should at least be 32 characters long, but the longer the better. You can use an online password generator and set the password length to 32 or longer.
BC_TIMEZONE
is used for cenverting dates from UTC to local time in emails. Must be a valid TZ idenfidier. Default is UTC.
The following settings are very important and if they are not set properly, authentication won't work:
BC_AUTH_COOKIE_DOMAIN=localhost
BC_ADMIN_HOST=http://localhost:3001/
BC_FRONTEND_HOST=http://localhost/
Replace localhost
with an IP or FQDN. That is if you access the admin panel from http://<FQDN>:3001/. BC_ADMIN_HOST
should be http://<FQDN>:3001/. The same goes for BC_FRONTEND_HOST
. And BC_AUTH_COOKIE_DOMAIN
should be FQDN.
Leave localhost
if you want to test locally.
If you want to enable push notifications in the mobile app, follow these instructions and set the following option:
BC_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN
If you want to enable stripe payment gateway, sign up for a stripe account, fill the forms and save the publishable key and the secret key from stripe dashboard. Then, set the secret key in the following option in api/.env:
BC_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
Don't expose stripe secret key on a website or embed it in a mobile application. It must be secret and stored securely in the server-side.
In stripe, all accounts have a total of four API keys by default-two for test mode and two for live mode:
- Test mode secret key: Use this key to authenticate requests on your server when in test mode. By default, you can use this key to perform any API request without restriction.
- Test mode publishable key: Use this key for testing purposes in your web or mobile app’s client-side code.
- Live mode secret key: Use this key to authenticate requests on your server when in live mode. By default, you can use this key to perform any API request without restriction.
- Live mode publishable key: Use this key, when you’re ready to launch your app, in your web or mobile app’s client-side code.
Use only your test API keys for testing. This ensures that you don't accidentally modify your live customers or charges.
If you want to use PayPal payment gateway instead of Stripe, you need to set:
BC_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
BC_PAYPAL_CLIENT_SECRET=PAYPAL_CLIENT_SECRET
If you want to test PayPal in sandbox mode, leave:
BC_PAYPAL_SANDBOX=true
If you want to test PayPal in production mode, set:
BC_PAYPAL_SANDBOX=false
If you want to use Google reCAPTCHA on the frontend, you need to set:
BC_RECAPTCHA_SECRET=RECAPTCHA_SECRET
- Create
./admin/.env.docker
file with the following content:
VITE_NODE_ENV=production
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_DEFAULT_LANGUAGE=en
VITE_BC_PAGE_SIZE=30
VITE_BC_CARS_PAGE_SIZE=15
VITE_BC_BOOKINGS_PAGE_SIZE=20
VITE_BC_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_TEMP_USERS=http://localhost:4002/cdn/bookcars/temp/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_TEMP_CARS=http://localhost:4002/cdn/bookcars/temp/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_TEMP_LOCATIONS=http://localhost:4002/cdn/bookcars/temp/locations
VITE_BC_CDN_CONTRACTS=http://localhost:4002/cdn/bookcars/contracts
VITE_BC_CDN_TEMP_CONTRACTS=http://localhost:4002/cdn/bookcars/temp/contracts
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
VITE_BC_SUPPLIER_IMAGE_WIDTH=60
VITE_BC_SUPPLIER_IMAGE_HEIGHT=30
VITE_BC_CAR_IMAGE_WIDTH=300
VITE_BC_CAR_IMAGE_HEIGHT=200
VITE_BC_MINIMUM_AGE=21
VITE_BC_PAGINATION_MODE=classic
VITE_BC_CURRENCY=\$
VITE_BC_DEPOSIT_FILTER_VALUE_1=250
VITE_BC_DEPOSIT_FILTER_VALUE_2=500
VITE_BC_DEPOSIT_FILTER_VALUE_3=750
VITE_BC_WEBSITE_NAME=BookCars
VITE_BC_CONTACT_EMAIL=[email protected]
VITE_BC_RECAPTCHA_ENABLED=false
VITE_BC_RECAPTCHA_SITE_KEY=GOOGLE_RECAPTCHA_SITE_KEY
Set the following options:
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_TEMP_USERS=http://localhost:4002/cdn/bookcars/temp/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_TEMP_CARS=http://localhost:4002/cdn/bookcars/temp/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_TEMP_LOCATIONS=http://localhost:4002/cdn/bookcars/temp/locations
VITE_BC_CDN_CONTRACTS=http://localhost:4002/cdn/bookcars/contracts
VITE_BC_CDN_TEMP_CONTRACTS=http://localhost:4002/cdn/bookcars/temp/contracts
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
If you want to change pagination mode, change VITE_BC_PAGINATION_MODE
option. You can choose between classic
or infinite_scroll
. This option defaults to classic
. If you choose classic
, you will get a classic pagination with next and previous buttons on desktop and infinite scroll on mobile. If you choose infinite_scroll
, you will get infinite scroll on desktop and mobile.
- Create
./frontend/.env.docker
file with the following content:
VITE_NODE_ENV=production
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_RECAPTCHA_ENABLED=false
VITE_BC_DEFAULT_LANGUAGE=en
VITE_BC_PAGE_SIZE=30
VITE_BC_CARS_PAGE_SIZE=15
VITE_BC_BOOKINGS_PAGE_SIZE=20
VITE_BC_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
VITE_BC_SUPPLIER_IMAGE_WIDTH=60
VITE_BC_SUPPLIER_IMAGE_HEIGHT=30
VITE_BC_CAR_IMAGE_WIDTH=300
VITE_BC_CAR_IMAGE_HEIGHT=200
VITE_BC_MINIMUM_AGE=21
VITE_BC_PAGINATION_MODE=classic # classic or infinite_scroll
VITE_BC_PAYMENT_GATEWAY=Stripe # Stripe or PayPal
VITE_BC_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_BC_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
VITE_BC_BASE_CURRENCY=USD
VITE_BC_SET_LANGUAGE_FROM_IP=false
VITE_BC_GOOGLE_ANALYTICS_ENABLED=false
VITE_BC_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX
VITE_BC_CONTACT_EMAIL=[email protected]
VITE_BC_DEPOSIT_FILTER_VALUE_1=250
VITE_BC_DEPOSIT_FILTER_VALUE_2=500
VITE_BC_DEPOSIT_FILTER_VALUE_3=750
VITE_BC_FB_APP_ID=XXXXXXXXXX
VITE_BC_APPLE_ID=XXXXXXXXXX
VITE_BC_GG_APP_ID=XXXXXXXXXX
VITE_BC_MIN_LOCATIONS=4
VITE_BC_WEBSITE_NAME=BookCars
VITE_BC_HIDE_SUPPLIERS=false
VITE_BC_MAP_LATITUDE=34.0268755 # Default map latitude
VITE_BC_MAP_LONGITUDE=1.6528399999999976 # Default map longitude
VITE_BC_MAP_ZOOM=5 # Default map zoom
Set the following options:
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
VITE_BC_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_BC_BASE_CURRENCY=USD
VITE_BC_SET_LANGUAGE_FROM_IP=false
VITE_BC_GOOGLE_ANALYTICS_ENABLED=false
VITE_BC_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX
VITE_BC_CONTACT_EMAIL=[email protected]
VITE_BC_FB_APP_ID=XXXXXXXXXX
VITE_BC_APPLE_ID=XXXXXXXXXX
VITE_BC_GG_APP_ID=XXXXXXXXXX
Leave localhost
if you want to test locally or Replace it with an IP, hostname or FQDN.
For Google Auth, you need to create OAuth 2.0 client ID and add your domains here and set VITE_BC_GG_APP_ID
. Do the samething for VITE_BC_APPLE_ID
here and VITE_BC_FB_APP_ID
here.
If you want to enable stripe payment gateway, set stripe publishable key in VITE_BC_STRIPE_PUBLISHABLE_KEY
. You can retrieve it from stripe dashboard.
VITE_BC_BASE_CURRENCY
is the three-letter ISO 4217 alphabetic currency code, e.g. "USD" or "EUR". Required for Stripe payments. Must be a supported currency: https://docs.stripe.com/currencies
If you want to change pagination mode, change VITE_BC_PAGINATION_MODE
option.
reCAPTCHA is by default disabled on the frontend. If you want to enable it, you have to set VITE_BC_RECAPTCHA_ENABLED
to true
and VITE_BC_RECAPTCHA_SITE_KEY
to Google reCAPTCHA site key.
Emails sent from the contact form are sent to:
VITE_BC_CONTACT_EMAIL=[email protected]
If you want to enable Google Analytics, set the following options:
VITE_BC_GOOGLE_ANALYTICS_ENABLED=true
VITE_BC_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX
If you want to use PayPal payment gateway instead of Stripe, you need to set this:
VITE_BC_PAYMENT_GATEWAY=PayPal # Stripe or PayPal
VITE_BC_PAYPAL_CLIENT_ID=PAYPAL_CLIENT_ID
You can find PayPal client id in PayPal Developer Dashboard.
- Open
./docker-compose.yml
and set MongoDB password:
services:
mongo:
image: mongo:latest
command: mongod --quiet --logpath /dev/null
restart: always
environment:
# Provide your credentials here
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- 27018:27017
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
mongo-express:
image: mongo-express:latest
restart: always
ports:
- 8084:8081
environment:
ME_CONFIG_MONGODB_URL: mongodb://admin:admin@mongo:27017/
ME_CONFIG_BASICAUTH_USERNAME: admin
ME_CONFIG_BASICAUTH_PASSWORD: admin
depends_on:
- mongo
bc-backend:
build:
context: .
dockerfile: ./backend/Dockerfile
env_file: ./backend/.env.docker
restart: always
ports:
- 4002:4002
depends_on:
- mongo
volumes:
- cdn:/var/www/cdn/bookcars
- backend_logs:/bookcars/backend/logs
bc-admin:
build:
context: .
dockerfile: ./admin/Dockerfile
depends_on:
- bc-backend
ports:
- 3001:3001
bc-frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
depends_on:
- bc-backend
ports:
- 8080:80
- 8443:443
volumes:
- cdn:/var/www/cdn/bookcars
volumes:
cdn:
mongodb_data:
mongodb_config:
backend_logs:
If you want to use MongoDB Atlas, remove mongo
container. Otherwise, replace admin
with the password that you have set in BC_DB_URI
in ./backend/.env.docker
.
- Build and run docker image:
docker compose up
To run the compose in background, add the -d
option with the command:
docker compose up -d
If you want to rebuild, use the following command:
docker compose up --build --force-recreate --no-deps bc-backend bc-admin bc-frontend
If you want to rebuild without cache, use the following commands:
docker compose build --no-cache bc-backend bc-admin bc-frontend
docker compose up
If you want to check the logs of the containers for troubleshooting, use the following command:
docker compose logs
That's it! You can access the services:
- Frontend: http://localhost:8080
- Admin Panel: http://localhost:3001
- Backend Server: http://localhost:4002
- MongoDB Express: http://localhost:8084
If you run BookCars for the first time, you'll start from an empty database. An admin user is automatically created with the email provided in BC_ADMIN_EMAIL
in backend/.env.docker
and B00kC4r5
as password. Change the password once you login to the admin panel.
Then, do the following:
- Go to the suppliers page and create one or multiple suppliers
- Go to the locations page and create one or multiple locations
- Go to the cars page and create one or multiple cars
- Go to the frontend, sign up, choose a car and checkout.
Finally, you will see bookings listed in the backend dashboard.
You can use the demo database if you want to.
Below are Docker configuration files:
- Backend Server: Dockerfile
- Admin Panel: Dockerfile
- Frontend: Dockerfile
- BookCars: docker-compose.yml
That's it. You can explore the other pages in the backend and the frontend.
This section will walk you through how to enable SSL in the API, the backend and the frontend in a docker container.
Copy your private key bookcars.key
and your certificate bookcars.crt
in ./
.
bookcars.key
will be loaded as /etc/ssl/bookcars.key
and bookcars.crt
will be loaded as /etc/ssl/bookcars.crt
in ./docker-compose.yml
.
For the API, update ./backend/.env.docker
as follows to enable SSL:
BC_HTTPS=true
BC_PRIVATE_KEY=/etc/ssl/bookcars.key
BC_CERTIFICATE=/etc/ssl/bookcars.crt
BC_BACKEND_HOST=http://localhost:3001/
BC_FRONTEND_HOST=http://localhost:8080/
Replace http://localhost
with https://<fqdn>
.
For the backend, update the following options in ./backend/.env.docker
:
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_TEMP_USERS=http://localhost:4002/cdn/bookcars/temp/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_TEMP_CARS=http://localhost:4002/cdn/bookcars/temp/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_TEMP_LOCATIONS=http://localhost:4002/cdn/bookcars/temp/locations
VITE_BC_CDN_CONTRACTS=http://localhost:4002/cdn/bookcars/contracts
VITE_BC_CDN_TEMP_CONTRACTS=http://localhost:4002/cdn/bookcars/temp/contracts
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
Replace http://localhost
with https://<fqdn>:4002
.
Then, update ./admin/nginx.conf
as follows to enable SSL:
server {
listen 3001 ssl;
root /usr/share/nginx/html;
index index.html;
ssl_certificate_key /etc/ssl/bookcars.key;
ssl_certificate /etc/ssl/bookcars.crt;
error_page 497 301 =307 https://$host:$server_port$request_uri;
access_log /var/log/nginx/backend.access.log;
error_log /var/log/nginx/backend.error.log;
location / {
# First attempt to serve request as file, then as directory,
# then as index.html, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
}
}
For the frontend, update the following options in ./frontend/.env.docker
:
VITE_BC_API_HOST=http://localhost:4002
VITE_BC_CDN_USERS=http://localhost:4002/cdn/bookcars/users
VITE_BC_CDN_CARS=http://localhost:4002/cdn/bookcars/cars
VITE_BC_CDN_LOCATIONS=http://localhost:4002/cdn/bookcars/locations
VITE_BC_CDN_LICENSES=http://localhost:4002/cdn/bookcars/licenses
VITE_BC_CDN_TEMP_LICENSES=http://localhost:4002/cdn/bookcars/temp/licenses
Replace http://localhost
with https://<fqdn>:4002
.
Then, update ./frontend/nginx.conf
as follows to enable SSL:
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
root /usr/share/nginx/html;
index index.html;
ssl_certificate_key /etc/ssl/bookcars.key;
ssl_certificate /etc/ssl/bookcars.crt;
access_log /var/log/nginx/frontend.access.log;
error_log /var/log/nginx/frontend.error.log;
location / {
# First attempt to serve request as file, then as directory,
# then as index.html, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
}
location /cdn {
alias /var/www/cdn;
}
}
Update ./docker-compose.yml
to load your private key bookcars.key
and your certificate bookcars.crt
, and add the port 443 to the frontend as follows:
services:
mongo:
image: mongo:latest
command: mongod --quiet --logpath /dev/null
restart: always
environment:
# Provide your credentials here
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- 27018:27017
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
mongo-express:
image: mongo-express:latest
restart: always
ports:
- 8084:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: admin
ME_CONFIG_MONGODB_SERVER: mongo
ME_CONFIG_BASICAUTH_USERNAME: admin
ME_CONFIG_BASICAUTH_PASSWORD: admin
depends_on:
- mongo
bc-backend:
build:
context: .
dockerfile: ./backend/Dockerfile
env_file: ./backend/.env.docker
restart: always
ports:
- 4002:4002
depends_on:
- mongo
volumes:
- cdn:/var/www/cdn/bookcars
- ./bookcars.key:/etc/ssl/bookcars.key
- ./bookcars.crt:/etc/ssl/bookcars.crt
bc-backend:
build:
context: .
dockerfile: ./backend/Dockerfile
depends_on:
- bc-backend
ports:
- 3001:3001
volumes:
- ./bookcars.key:/etc/ssl/bookcars.key
- ./bookcars.crt:/etc/ssl/bookcars.crt
bc-frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
depends_on:
- bc-backend
ports:
- 8080:80
- 8443:443
volumes:
- cdn:/var/www/cdn/bookcars
- ./bookcars.key:/etc/ssl/bookcars.key
- ./bookcars.crt:/etc/ssl/bookcars.crt
volumes:
cdn:
mongodb_data:
mongodb_config:
Rebuild and run Docker image:
docker compose build --no-cache api backend frontend
docker compose up