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

https://github.com/notyusheng/dockerized-offline-react-apps-using-tarballs

Cache React app dependencies offline with tarballs, enabling npm install without internet access during deployment.
https://github.com/notyusheng/dockerized-offline-react-apps-using-tarballs

docker npm package-json react tarballs

Last synced: 3 months ago
JSON representation

Cache React app dependencies offline with tarballs, enabling npm install without internet access during deployment.

Awesome Lists containing this project

README

          

# Dockerized Offline React Apps Using Tarballs
Cache React app dependencies offline with tarballs, enabling `npm install` without internet access during deployment.

## Prerequisites
- Local installation of Node.js and npm.
- A basic React app with a package.json file.
- Docker installed (if using containerized builds).

## Steps to follow
1. Download the `create-tarballs.sh` script and ensure it is set to executable before running it.
```
git clone https://github.com/NotYuSheng/Dockerized-Offline-React-Apps-Using-Tarballs.git
cd Dockerized-Offline-React-Apps-Using-Tarballs
```
2. Run the `create-tarballs.sh` script in the directory containing your `package.json`.
```
./create-tarballs.sh
```
This will:
- Install the dependencies using `npm install`.
- Create tarballs for each dependency.
- Save the tarballs in the `tarballs/` directory.
3. Modify the Dockerfile Use the `example/Dockerfile` as a reference for building your app with tarballs.
- Copy the tarballs directory into the Docker image.
- Update the `npm install` command to install from tarballs.
4. Build and run your docker container

## Important Note: EOL Conversion for Shell Scripts

If you encounter issues running the `create-tarballs.sh` script, it may be due to differences in end-of-line (EOL) characters. This is a common issue when shell scripts are created or edited on Windows systems, as they use Windows-style EOL (`\r\n`) instead of the Unix-style EOL (`\n`) required by Linux.

To resolve this issue, ensure the script uses Unix-style EOL. You can convert the script using the tool provided in [NotYuSheng/eol-converter](https://github.com/NotYuSheng/eol-converter). This applies regardless of whether you're running the script on Linux or Docker containers.

#### Quick Fix
If you suspect this issue:
1. Use `dos2unix` (if installed) to convert the script:
```bash
dos2unix create-tarballs.sh
```
2. Alternatively, run the [EOL converter tool](https://github.com/NotYuSheng/eol-converter) for a more streamlined fix.