javiertrombetta/box-back
Box is a last-mile logistics application. Also get javiertrombetta/box-front for full-project use.
532
Box is a last-mile logistics application.
Create an empty folder somewhere your computer directory.
Inside the new folder, create a docker-compose.yml file and copy the following code:
version: '3.1'
services:
boxapi:
depends_on:
- boxdb
build:
target: ${NODE_ENV}
context: .
dockerfile: Dockerfile
image: javiertrombetta/box-back:latest
container_name: boxapi
restart: always
ports:
- '${PORT}:${PORT}'
environment:
TZ: ${TIME_ZONE}
NODE_ENV: ${NODE_ENV}
CORS_ORIGIN: ${CORS_ORIGIN}
CORS_METHODS: ${CORS_METHODS}
GLOBAL_PREFIX: ${GLOBAL_PREFIX}
PORT: ${PORT}
MONGODB_URI: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_DB_NAME}
MONGO_USERNAME: ${MONGO_USERNAME}
MONGO_PASSWORD: ${MONGO_PASSWORD}
MONGO_DB_NAME: ${MONGO_DB_NAME}
JWT_SECRET: ${JWT_SECRET}
SMTP_FROM: ${SMTP_FROM}
SMTP_SERVICES: ${SMTP_SERVICES}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT}
SMTP_USER: ${SMTP_USER}
SMTP_PASSWORD: ${SMTP_PASSWORD}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
GOOGLE_TRAVEL_MODE: ${GOOGLE_TRAVEL_MODE}
GOOGLE_ROUTING_PREFERENCE: ${GOOGLE_ROUTING_PREFERENCE}
GOOGLE_RESPONSE_FILEDS: ${GOOGLE_RESPONSE_FILEDS}
GOOGLE_OAUTH_WEB_CLIENT_ID: ${GOOGLE_OAUTH_WEB_CLIENT_ID}
GOOGLE_OAUTH_WEB_SECRET: ${GOOGLE_OAUTH_WEB_SECRET}
GOOGLE_OAUTH_WEB_CALLBACK_URL: ${GOOGLE_OAUTH_WEB_CALLBACK_URL}
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_REGION: ${AWS_REGION}
boxdb:
image: mongo:7.0.6
volumes:
- box-vol:/data/db
container_name: ${MONGO_DB_NAME}
restart: always
environment:
MONGO_USERNAME: ${MONGO_USERNAME}
MONGO_PASSWORD: ${MONGO_PASSWORD}
MONGO_DB_NAME: ${MONGO_DB_NAME}
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
command: ['--auth']
volumes:
box-vol:
external: false
Create a new file /.env
with the following enviroment variables:
Enviroment Variable name | Example | Description |
---|---|---|
GLOBAL_PREFIX | api/v1 | The prefix for all routes in the API |
PORT | 3000 | The port number on which the server will run |
NODE_ENV | production | Specifies the environment in which an application is running. Use production in order to work. |
TZ | America/Argentina/Buenos_Aires | Check your time zone from this list and write the correct one. |
Enviroment Variable name | Example | Description |
---|---|---|
CORS_ORIGIN | https://domain.com | The origin that is allowed to access the server, for CORS (Cross-Origin Resource Sharing) |
CORS_METHODS | GET,POST,PUT,DELETE | Specifies the HTTP methods that are allowed when accessing the resource in a cross-origin manner. Use the methods GET, POST, PUT, and DELETE as described for full CRUD operations of the RestAPI. |
Enviroment Variable name | Example | Description |
---|---|---|
MONGO_USERNAME | example_user | The username for MongoDB authentication |
MONGO_PASSWORD | example_password | The password for MongoDB authentication |
MONGO_DB_NAME | example_db | The database name to connect to in MongoDB |
Enviroment Variable name | Example | Description |
---|---|---|
JWT_SECRET | EXAMPLE_JASON_WEB_TOKEN_FOR_ENCYPT | The secret key for encoding and decoding JSON Web Tokens |
Enviroment Variable name | Example | Description |
---|---|---|
SMTP_FROM= | write_app_name <name@domain.com> | The email address that will appear as the sender |
SMTP_SERVICES | write_mail_service | The email service provider (e.g., Gmail, Outlook) |
SMTP_HOST | write_mail_host | The SMTP host for the email service |
SMTP_PORT | write_mail_port | The port number for the SMTP service |
SMTP_USER | write_mail_account | The username/email for the SMTP service |
SMTP_PASSWORD | write_mail_password_or_token | The password or token for the SMTP service authentication |
Enviroment Variable name | Example | Description |
---|---|---|
GOOGLE_MAPS_API_KEY | write_google_platform_token | The API key for accessing Google Maps services |
GOOGLE_TRAVEL_MODE | TWO_WHEELER | The mode of travel for routing (e.g., driving, walking) |
GOOGLE_ROUTING_PREFERENCE | TRAFFIC_AWARE | The routing preference for Google Maps directions |
GOOGLE_RESPONSE_FILEDS | * | The fields to include in the response from Google Maps services |
Run the following command into a console terminal:
$ docker compose up
docker pull javiertrombetta/box-back