Skip to content

Commit

Permalink
Merge pull request #7 from oasysgames/fix/Dockerfile
Browse files Browse the repository at this point in the history
enable to set allow_list before docker_container start
  • Loading branch information
Tsuyoshi-Ishikawa authored Nov 9, 2022
2 parents 1963de3 + fb74dd0 commit e026d96
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 45 deletions.
26 changes: 4 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
###################
## BUILD
###################
FROM node:18-alpine As build
FROM node:18-alpine
RUN mkdir -p /usr/src/app && chown -R node:node /usr/src/app
WORKDIR /usr/src/app

# COPY --chown=node:node package*.json ./
# COPY --chown=node:node . .

# USER node

COPY package*.json ./
COPY --chown=node:node . .
RUN npm install
COPY . .
RUN npm run build

###################
## PRODUCTION
###################
FROM node:18-alpine As production

COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist

USER node

CMD [ "node", "dist/main.js" ]
CMD ["npm", "run", "start"]
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ $ npm run test:cov
```

### Deploy
#### 1. Set PORT
```bash
# create image
docker build . --tag verse-layer-proxy
export PORT=[YOUR_PROXY_PORT]
```

#### 2. Set allow list config
You have to download your allow list config to `$PWD/src/config`.

#### 3. Start container
```bash
# chose image version and pull image
docker pull ghcr.io/oasysgames/verse-proxy:v1.0.0

# create container
docker run --name verse-layer-proxy -d -p 3000:3000 verse-layer-proxy
docker run --name verse-proxy -d -p $PORT:$PORT -v $PWD/src/config:/usr/src/app/src/config verse-proxy
```

## Control items
Expand Down
15 changes: 14 additions & 1 deletion src/config/transactionAllowList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import { TransactionAllow } from 'src/shared/entities';
export interface ComparisonOperation {
eq?: string; // txValue == condition is allowed
nq?: string; // txValue != condition is allowed
gt?: string; // txValue > condition is allowed
gte?: string; // txValue >= condition is allowed
lt?: string; // txValue < condition is allowed
lte?: string; // txValue <= condition is allowed
}

export interface TransactionAllow {
fromList: Array<string>;
toList: Array<string>;
value?: ComparisonOperation;
}

export const getTxAllowList = (): Array<TransactionAllow> => {
return [
Expand Down
6 changes: 4 additions & 2 deletions src/services/transaction.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Injectable } from '@nestjs/common';
import { ethers, BigNumber, Transaction } from 'ethers';
import {
TransactionAllow,
EthEstimateGasParams,
JsonrpcRequestBody,
JsonrpcId,
JsonrpcVersion,
JsonrpcError,
} from 'src/shared/entities';
import { AllowCheckService } from 'src/shared/services/src';
import { getTxAllowList } from 'src/config/transactionAllowList';
import {
TransactionAllow,
getTxAllowList,
} from 'src/config/transactionAllowList';
import { VerseService } from './verse.service';

@Injectable()
Expand Down
14 changes: 0 additions & 14 deletions src/shared/entities/TransactionAllow.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/shared/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './TransactionAllow';
export * from './TransactionParam';
export * from './Jsonrpc';
export * from './Verse';
Expand Down
5 changes: 4 additions & 1 deletion src/shared/services/src/__tests__/allowCheck.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { BigNumber } from 'ethers';
import { ComparisonOperation, TransactionAllow } from 'src/shared/entities';
import {
TransactionAllow,
ComparisonOperation,
} from 'src/config/transactionAllowList';
import { AllowCheckService } from '../allowCheck.service';
import * as transactionAllowList from 'src/config/transactionAllowList';

Expand Down
5 changes: 4 additions & 1 deletion src/shared/services/src/allowCheck.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Injectable } from '@nestjs/common';
import { TransactionAllow, ComparisonOperation } from 'src/shared/entities';
import {
TransactionAllow,
ComparisonOperation,
} from 'src/config/transactionAllowList';
import { BigNumber } from 'ethers';
import { getDeployAllowList } from 'src/config/transactionAllowList';

Expand Down

0 comments on commit e026d96

Please sign in to comment.