Code Monkey home page Code Monkey logo

be-assignment's Introduction

How to use this app

This project uses Fastify, Prisma, and Docker. This guide will help you set up and run the application using Docker.

For API usage you can go this link: API Usage

Prerequisites

Make sure you have the following installed on your machine:

  • Docker
  • Docker Compose

Project Setup

1. Clone the Repository

git clone https://github.com/hafidhsajid/be-assignment.git
cd be-assignemt

2. Clone the Repository

Create a .env file in the root of the project with the following content:

DATABASE_URL=postgresql://postgres:password@db:5432/mydb
JWT_SECRET=SecretJWT

3. Docker Setup

3.1 Build Docker Images and Start Containers

Run the following command to build the Docker images and start the containers:

docker-compose up --build

This command will:

  • Build the Docker image for the Fastify application using the Dockerfile.
  • Start the PostgreSQL database and Fastify application services.
  • Apply Prisma migrations and seed the database.

3.2 Run Migrations and Seed Data

If you need to manually apply migrations and seed data (e.g., after modifying the database schema), you can run:

docker-compose run --rm app npm run migrate
docker-compose run --rm app npm run seed

npm run migrate will apply any pending Prisma migrations. npm run seed will seed the database with initial data. ###4. Access the Application Once the containers are running, you can access the Fastify application at

http://localhost:3000

5. Stopping the Application

To stop the application and remove the containers, run:

docker-compose down

6. Troubleshooting

Check Logs: If you encounter issues, check the logs for more information:

docker-compose logs

Restart Services: To restart the services, you can use:

docker-compose restart

Additional Commands Rebuild and Start: To rebuild the Docker image and start the application:

docker-compose up --build

Remove Volumes: To remove Docker volumes, which might be useful for cleaning up:

docker-compose down -v

Summary

This `README.md` provides comprehensive instructions for setting up and running your Dockerized Fastify application, including how to build, run, and manage Docker containers, apply migrations, and handle troubleshooting. Adjust the commands and instructions as needed for your specific project details and requirements.

be-assignment's People

Contributors

hafidhsajid avatar ca-dev1 avatar c-e-ooi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.