Sign inSign up

javiertrombetta/capif-back

By javiertrombetta

Updated over 1 year ago
Archived

Image
0

5.9K

javiertrombetta/capif-back repository overview

CAPIF RestAPI

CAPIF GIT is a management system designed for the administration of the music industry.

Step 1

Verify Docker version

docker --version

Step 2

Create an empty folder somewhere your computer directory.

Step 3

Inside the new folder, create a docker-compose.yml file and copy the following code:

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: javiertrombetta/capif-back:latest
    container_name: capif-back
    entrypoint: /usr/src/app/entrypoint.sh
    restart: always
    ports:
      - '${PORT}:${PORT}'
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:      
      DB_USER: ${DB_USER}
      DB_PASSWORD: ${DB_PASSWORD}
      DB_NAME: ${DB_NAME}
      DB_HOST: ${DB_HOST}
      DB_PORT: ${DB_PORT}
      NODE_ENV: production
      JWT_SECRET: ${JWT_SECRET}
      GLOBAL_PREFIX: ${GLOBAL_PREFIX}
      PORT: ${PORT}
      RESET_TOKEN_EXPIRATION: ${RESET_TOKEN_EXPIRATION}
      MAX_LOGIN_ATTEMPTS: ${MAX_LOGIN_ATTEMPTS}
      ALLOWED_FILE_TYPES: ${ALLOWED_FILE_TYPES}
      REDIS_HOST: ${REDIS_HOST}
      REDIS_PORT: ${REDIS_PORT}
      TZ: ${TZ}
      FRONTEND_URL: ${FRONTEND_URL}
      SMTP_SERVICE: ${SMTP_SERVICE}
      SMTP_FROM: ${SMTP_FROM}
      SMTP_USER: ${SMTP_USER}
      SMTP_PASS: ${SMTP_PASS}
    networks:
      - capif-net

  postgres:
    image: postgres:15.8-alpine3.20
    container_name: postgres
    restart: always
    ports:
      - '5432:5432'
    environment:
      TZ: ${TZ}
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - postgresdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
      interval: 10s
      retries: 5
      start_period: 30s
      timeout: 10s
    networks:
      - capif-net

  redis:
    image: redis:alpine3.20
    container_name: redis
    restart: always
    ports:
      - '6379:6379'
    environment:
      TZ: ${TZ}
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - capif-net

volumes:
  postgresdata:

networks:
  capif-net:
    driver: bridge

Step 4

Create a new file /.env with the following enviroment variables:

GLOBALS Configuration
Enviroment Variable nameExampleDescription
GLOBAL_PREFIXapi/v1The prefix for all routes in the API
PORT3000The port number on which the server will run
NODE_ENVproductionSpecifies the environment in which an application is running. Use production in order to work.
TZAmerica/Argentina/Buenos_AiresCheck your time zone from this list and write the correct one.
CORS Configuration
Enviroment Variable nameExampleDescription
CORS_ORIGINhttps://domain.comThe origin that is allowed to access the server, for CORS (Cross-Origin Resource Sharing)
CORS_METHODSGET,POST,PUT,DELETESpecifies 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.
PostgreSQL Configuration
Enviroment Variable nameExampleDescription
POSTGRES_USERexample_userThe username for PostgreSQL authentication
POSTGRES_PASSWORDexample_passwordThe password for PostgreSQL authentication
POSTGRES_DBexample_dbThe database name to connect to in PostgreSQL
Json Web Token Configuration
Enviroment Variable nameExampleDescription
JWT_SECRETEXAMPLE_JASON_WEB_TOKEN_FOR_ENCYPTThe secret key for encoding and decoding JSON Web Tokens

# Nodemailer Configuration

Enviroment Variable nameExampleDescription
SMTP_FROM=write_app_name <[email protected]>The email address that will appear as the sender
SMTP_SERVICESwrite_mail_serviceThe email service provider (e.g., Gmail, Outlook)
SMTP_HOSTwrite_mail_hostThe SMTP host for the email service
SMTP_PORTwrite_mail_portThe port number for the SMTP service
SMTP_USERwrite_mail_accountThe username/email for the SMTP service
SMTP_PASSWORDwrite_mail_password_or_tokenThe password or token for the SMTP service authentication

Step 5

Run the following command into a console terminal: $ docker compose up -d

EXTRA

Run the following command into a console terminal just to delete everything: $ docker compose down -v && docker rmi javiertrombetta/capif-back:latest

Tag summary

Content type

Image

Digest

sha256:ebbf4d737

Size

98.6 MB

Last updated

over 1 year ago

docker pull javiertrombetta/capif-back