Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

node.js - How to Dockerize node+postgres?

I'm pretty new to Docker and I was asked to write an api with node, express and postgres and dockerize it.

I created the Dockerfile:

FROM node:12.12.0-alpine

WORKDIR /app

COPY package*.json ./ 
RUN npm install
COPY . . 

EXPOSE 3000

CMD [ "npm", "start" ] 

And the docker-compose.yml:

version: "3"
services:
  app:
    build: .
    command: sh -c "npm run migrate up && npm start"
    ports:
      - 3000:3000
    working_dir: /app
    depends_on:
      - db
    environment:
      - DATABASE_URL=postgres://root:password@db:5432/chargeflow
  db:
    image: postgres
    environment:
      - POSTGRES_USER=root
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=chargeflow
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - ./db/data/postgres:/var/lib/postgresql/data
    ports:
      - 5432:5432

But when i build the docker-compose is get this errors/warnings:

app_1  | 
app_1  | > [email protected] migrate /app
app_1  | > node-pg-migrate "up"
app_1  | 
app_1  | Can't determine timestamp for 20210128200430-create-tweet
app_1  | Can't determine timestamp for 20210128200611-create-like
app_1  | Can't determine timestamp for 20210128200656-create-re-tweet
app_1  | > Migrating files:
app_1  | > - 20210128200430-create-tweet
app_1  | > - 20210128200611-create-like
app_1  | > - 20210128200656-create-re-tweet

What I'm doing wrong?

Thanks!

question from:https://stackoverflow.com/questions/65947221/how-to-dockerize-nodepostgres

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...