chore: add docker configuration

staging
shancheas 2024-07-01 11:09:19 +07:00
parent 8db2256852
commit 2c46650e43
2 changed files with 12 additions and 7 deletions

View File

@ -5,10 +5,7 @@ COPY . .
RUN yarn install RUN yarn install
RUN yarn build RUN yarn build
FROM node:18.17-alpine FROM node:18.17-alpine
ARG env_target
WORKDIR /app WORKDIR /app
RUN echo ${env_target}
COPY env/$env_target /app/.env
COPY --from=builder /app/env/$env_target .env COPY --from=builder /app/env/$env_target .env
COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist COPY --from=builder /app/dist ./dist

View File

@ -8,7 +8,9 @@ export class CouchService {
constructor(private eventBus: EventBus) {} constructor(private eventBus: EventBus) {}
async onModuleInit() { async onModuleInit() {
const nano = require('nano')('http://root:password@172.10.10.2:5970'); const nano = require('nano')(
'http://root:password@db_pos_couch_staging:5984',
);
for (const database of DatabaseListen) { for (const database of DatabaseListen) {
const db = nano.db.use(database); const db = nano.db.use(database);
db.changesReader.start({ includeDocs: true }).on('change', (change) => { db.changesReader.start({ includeDocs: true }).on('change', (change) => {
@ -31,7 +33,9 @@ export class CouchService {
public async createDoc(data, database) { public async createDoc(data, database) {
try { try {
const nano = require('nano')('http://root:password@172.10.10.2:5970'); const nano = require('nano')(
'http://root:password@db_pos_couch_staging:5984',
);
const db = nano.use(database); const db = nano.use(database);
return await db.insert(data); return await db.insert(data);
} catch (error) {} } catch (error) {}
@ -39,7 +43,9 @@ export class CouchService {
public async deleteDoc(data, database) { public async deleteDoc(data, database) {
try { try {
const nano = require('nano')('http://root:password@172.10.10.2:5970'); const nano = require('nano')(
'http://root:password@db_pos_couch_staging:5984',
);
const db = nano.use(database); const db = nano.use(database);
const result = await db.get(data.id); const result = await db.get(data.id);
await db.destroy(data.id, result._rev); await db.destroy(data.id, result._rev);
@ -48,7 +54,9 @@ export class CouchService {
public async updateDoc(data, database) { public async updateDoc(data, database) {
try { try {
const nano = require('nano')('http://root:password@172.10.10.2:5970'); const nano = require('nano')(
'http://root:password@db_pos_couch_staging:5984',
);
const db = nano.use(database); const db = nano.use(database);
const result = await db.get(data.id); const result = await db.get(data.id);
console.log(result, 'dsa'); console.log(result, 'dsa');