Skip to content

Commit

Permalink
update(file):
Browse files Browse the repository at this point in the history
- Added missing variables to .example.env
- Updated docker compose file
- Updated environment file
- Fixed worker path in server.ts
- Fixed Bull-Board not using port environment variable
  • Loading branch information
bootsie123 committed Jun 29, 2024
1 parent 62c2446 commit b0e53fd
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ NEW_STORAGE_ID=
ADD_JOBS=
REDIS_HOST=
REDIS_PORT=
BULLMQ_PORT=
BULLMQ_RESET_QUEUES=
CONCURRENCY=
DRY_RUN=
124 changes: 122 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,123 @@
# Iconik Proxy Migrator
# Iconik Storage Migrator

Migrates proxies in Iconik to another storage location
Allows for seamless migration of different object types in Iconik to different storage locations.

Simply install the application locally or with [Docker Compose](https://docs.docker.com/compose/), configure the settings to your liking, and watch it go with the included dashboard!

## Features

- Proxy migration
- Concurrency
- Dry run mode which allows for testing without making changes
- Easily deployable through Docker

## Installation

**_Note: Certain project settings must be configured before it can be ran_**

### Local

First, clone the repository using [git](https://git-scm.com/) and then use [npm](https://www.npmjs.com/) to install the necessary node modules. If [Node.js](https://nodejs.org/) is not already installed, please do so before running npm.

```bash
# Clone the repository
git clone https://github.com/bootsie123/iconik-storage-migrator.git

# Enter the directory
cd iconik-storage-migrator

# Install the dependencies
npm install

# Copy example .env file
cp .example.env .env

# Configure the required environment variables
nano .env
```

### Docker

Alternatively, you can install and configure the application with [Docker Compose](https://docs.docker.com/compose/).

```bash
# Clone the repository
git clone https://github.com/bootsie123/iconik-storage-migrator.git

# Enter the directory
cd iconik-storage-migrator

# Configure the required environment variables
nano docker-compose.yml
```

## Configuration

In order to run the app, the following configuration options must be set in the `.env` file or within `docker-compose.yml`.

| Name | Type | Default | Description |
| -------------- | ------ | --------- | ------------------------------------------------- |
| ICONIK_APP_ID | String | | The ID of the Iconik application token to use |
| ICONIK_TOKEN | String | | The token of the Iconik application token to use |
| NEW_STORAGE_ID | String | | The ID of the storage location to migrate to |
| REDIS_HOST\* | String | localhost | The ip address or correction URL to use for Redis |
| REDIS_PORT\* | Number | 6379 | The port to use for Redis |

_Only needed if specifically running locally_

### Application Settings

The following table shows the various configurations options which can be set and their default values. These settings can be set in the `.env` file (for local deployment) or within `docker-compose.yml` if using Docker Compose.

| Name | Type | Default | Description |
| ------------------- | ------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| ICONIK_APP_ID | String | | The ID of the Iconik application token to use |
| ICONIK_TOKEN | String | | The token of the Iconik application token to use |
| NEW_STORAGE_ID | String | | The ID of the storage location to migrate to |
| REDIS_HOST\* | String | `redis` if production, otherwise `localhost` | The ip address or correction URL to use for Redis |
| REDIS_PORT\* | Number | 6379 | The port to use for Redis |
| ADD_JOBS | Boolean | true | Set to true if jobs should automatically be generated and added to their respective queues, otherwise if false, only existing jobs will be processed |
| CONCURRENCY | Number | 10 | The number of concurrent jobs to process per worker |
| BULLMQ_PORT | Number | 3000 | The port to use for the dashboard |
| BULLMQ_RESET_QUEUES | Boolean | false | Set to true if all queues should be reset and jobs removed on start, false if otherwise |
| DRY_RUN | Boolean | `true` if production, otherwise `false` | Determines whether dry run mode is enabled. In dry run mode, no changes are made and instead logged to the console |

## Usage

### Local

To start the application locally simply run:

```bash
npm run build

npm start
```

This will start the migration and launch a progress dashboard on port `3000` by default. You can connect to it via `http://localhost:3000/status` or through the IP address of your computer `http://192.168.x.x:3000/status`

### Docker

To start the application with Docker, simply run:

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

From there, you can then access the progress dashboard on port `3000` by default of your Docker host. For example: `http://192.168.x.x:3000/status`

#### Logging

To see all logs, simply run:

```bash
docker compose logs -f
```

## Contributing

Pull requests are welcome. Any changes are appreciated!

## License

This project is licensed under the [MIT License](https://choosealicense.com/licenses/mit/)
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ services:
app:
build:
context: ./
target: development
target: production
depends_on:
- redis
environment:
ICONIK_APP_ID:
ICONIK_TOKEN:
Expand Down
6 changes: 5 additions & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export default {
newStorageId: process.env.NEW_STORAGE_ID || ""
},
redis: {
host: process.env.REDIS_HOST || "localhost",
host:
process.env.REDIS_HOST === undefined &&
process.env.NODE_ENV === "production"
? "redis"
: process.env.REDIS_HOST || "localhost",
port: parseInt(process.env.REDIS_PORT || "6379")
},
addJobs:
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for (let i = 0; i < cores; i++) {
workers.push(
new Worker(
environment.bullmq.queueName,
path.join(__dirname, "/workers/proxyStorageMigration.js"),
path.join(__dirname, "/workers/proxyMigration.js"),
{
connection: environment.redis,
concurrency: environment.concurrency,
Expand Down
4 changes: 2 additions & 2 deletions src/services/QueueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default class QueueService {

app.use("/status", serverAdapter.getRouter());

app.listen(3000, () => {
this.logger.info("Running Bull-Board on port 3000");
app.listen(environment.bullmq.port, () => {
this.logger.info(`Running dashboard on port ${environment.bullmq.port}`);
});
}

Expand Down

0 comments on commit b0e53fd

Please sign in to comment.