Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cslant/react-docker

This is a simple docker configuration for React. It is suitable for both development and production environments.
https://github.com/cslant/react-docker

cslant cslant-docker docker docker-compose docker-template docker-templates react-docker react-environnement reactjs

Last synced: 10 days ago
JSON representation

This is a simple docker configuration for React. It is suitable for both development and production environments.

Awesome Lists containing this project

README

        

# Docker for React

This is a simple docker configuration for React. It is suitable for both development and production environments.

## For development

First, update the **APP_CONTAINER_NAME** and **APP_PORT** variables in the .env file if you want to change the container name and the port number.

```bash
cp .env.example .env
```

And change variables. Example:

```dotenv
APP_CONTAINER_NAME=react-app
APP_PORT=3001
```

Then, run the following command to start the development server:

```bash
docker compose up -d
```

Now, you can access the development server at http://localhost:3001.

## For production

First, update the **APP_CONTAINER_NAME** and **APP_PORT** variables in the .env file if you want to change the container name and the port number.

```bash
cp .env.example .env
```

And change variables. Example:

```dotenv
APP_CONTAINER_NAME=react-app-prod
PROD_APP_PORT=85
```

Then, run the following command to build the production image:

```bash
docker compose -f docker-compose.prod.yml up -d --build
```

Now, you can access the production server at http://localhost:85.

> [!IMPORTANT]
> ## Note
> Every time you change the source code, you need to rebuild the image by running the above command again.