所以基本上我是使用docker-compose一起运行3个服务。这些服务包括应用程序的UI,PostgreSQL数据库和应用程序的API服务器。
目前我已经尝试使用docker-compose up命令运行docker-compose.yaml,目前我能够看到应用程序的UI,但是在UI页面本身中可以选择创建新文件夹。在UI页面中创建新文件夹的选项不起作用。这显然意味着api服务器无法正常工作。
version: "3"
services:
pg_db:
image: postgres
networks:
- wootzinternal
ports:
- 5432
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=postgres
- POSTGRES_DB=wootz
volumes:
- wootz-db:/var/lib/postgresql/data
apiserver:
image: wootz-backend
volumes:
- ./api:/usr/src/app
- /usr/src/app/node_modules
build:
context: ./api
dockerfile: Dockerfile
networks:
- wootzinternal
depends_on:
- pg_db
ports:
- '8000:8000'
ui:
image: wootz-frontend
volumes:
- ./client:/usr/src/app
- /usr/src/app/build
- /usr/src/app/node_modules
build:
context: ./client
dockerfile: Dockerfile
networks:
- wootzinternal
ports:
- '80:3000'
volumes:
wootz-db:
networks:
wootzinternal:
driver: bridge
用于api服务器的Dockerfile
FROM node:12.4.0-alpine
RUN mkdir -p usr/src/app
WORKDIR /usr/src/app
COPY package.json package.json
RUN npm install && npm cache clean --force
WORKDIR /usr/src/app
COPY . .
WORKDIR /usr/src/app
EXPOSE 8000
CMD [ "npm","start" ]
用于应用程序的UI(客户端)的Dockerfile
FROM node:12.4.0-alpine
RUN mkdir -p usr/src/app
WORKDIR /usr/src/app
COPY package.json package.json
RUN npm install && npm cache clean --force
WORKDIR /usr/src/app
COPY . .
WORKDIR /usr/src/app
EXPOSE 3000
RUN npm run build
CMD [ "npm","start" ]
使用dockerfile创建api映像时使用的config.json
{
"development": {
"username": "postgres",
"password": "password",
"database": "wootz",
"host": "pg_db",
"dialect": "postgres"
},
"test": {
"username": "postgres",
"password": "password",
"database": "wootz",
"host": "pg_db",
"dialect": "postgres"
},
"production": {
"username": "postgres",
"password": "password",
"database": "wootz",
"host": "pg_db",
"dialect": "postgres"
}
}
运行npm的日志在api服务器容器中迁移
/usr/src/app # npm run migrate
> wootz-backend@1.0.0 migrate /usr/src/app
> sequelize db:migrate --config config/config.json
Sequelize CLI [Node: 12.4.0, CLI: 5.4.0, ORM: 5.8.7]
Loaded configuration file "config/config.json".
Using environment "development".
== 20190604071255-create-folders: migrating =======
== 20190604071255-create-folders: migrated (0.027s)
== 20190604072132-create-views: migrating =======
== 20190604072132-create-views: migrated (0.018s)
docker-compose的日志
vignesh@master-node:~/cors new files$ sudo docker-compose logs
sudo: unable to resolve host master-node
Attaching to corsnewfiles_apiserver_1, corsnewfiles_ui_1, corsnewfiles_pg_db_1
apiserver_1 |
apiserver_1 | > wootz-backend@1.0.0 start /usr/src/app
apiserver_1 | > nodemon index.js
apiserver_1 |
apiserver_1 | [nodemon] 1.19.1
apiserver_1 | [nodemon] to restart at any time, enter `rs`
apiserver_1 | [nodemon] watching: *.*
apiserver_1 | [nodemon] starting `node index.js`
apiserver_1 | {
apiserver_1 | username: 'postgres',
apiserver_1 | password: 'password',
apiserver_1 | database: 'wootz',
apiserver_1 | host: 'pg_db',
apiserver_1 | dialect: 'postgres'
apiserver_1 | }
apiserver_1 | folders
apiserver_1 | views
apiserver_1 | Listening on port 8000
pg_db_1 | The files belonging to this database system will be owned by user "postgres".
pg_db_1 | This user must also own the server process.
pg_db_1 |
pg_db_1 | The database cluster will be initialized with locale "en_US.utf8" .
pg_db_1 | The default database encoding has accordingly been set to "UTF8".
pg_db_1 | The default text search configuration will be set to "english".
pg_db_1 |
pg_db_1 | Data page checksums are disabled.
pg_db_1 |
pg_db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
pg_db_1 | creating subdirectories ... ok
pg_db_1 | selecting default max_connections ... 100
pg_db_1 | selecting default shared_buffers ... 128MB
pg_db_1 | selecting default timezone ... Etc/UTC
ui_1 |
pg_db_1 | selecting dynamic shared memory implementation ... posix
ui_1 | > wootz@0.1.0 start /usr/src/app
pg_db_1 | creating configuration files ... ok
ui_1 | > node scripts/start.js
pg_db_1 | running bootstrap script ... ok
ui_1 |
pg_db_1 | performing post-bootstrap initialization ... ok
ui_1 | Starting the development server...
pg_db_1 |
ui_1 |
pg_db_1 | WARNING: enabling "trust" authentication for local connections
ui_1 | Compiled with warnings.
pg_db_1 | You can change this by editing pg_hba.conf or using the option -A , or
ui_1 |
pg_db_1 | --auth-local and --auth-host, the next time you run initdb.
ui_1 | ./src/registeredComponent/temporary/temporary.js
pg_db_1 | syncing data to disk ... ok
ui_1 | Line 1: 'Component' is defined but never used no-unused-vars
pg_db_1 |
ui_1 |
pg_db_1 | Success. You can now start the database server using:
ui_1 | ./src/registeredComponent/textFiled/textFiled.js
pg_db_1 |
ui_1 | Line 1: 'Component' is defined but never used no-unused-vars
ui_1 |
ui_1 | ./src/components/Data/dragAndDrop/master.js
pg_db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
pg_db_1 |
pg_db_1 | waiting for server to start....2019-07-03 05:49:53.111 UTC [43] L OG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pg_db_1 | 2019-07-03 05:49:53.128 UTC [44] LOG: database system was shut d own at 2019-07-03 05:49:52 UTC
pg_db_1 | 2019-07-03 05:49:53.133 UTC [43] LOG: database system is ready t o accept connections
pg_db_1 | done
ui_1 | Line 22: 'Link' is defined but never used no-unused-vars
pg_db_1 | server started
pg_db_1 | CREATE DATABASE
ui_1 |
pg_db_1 |
ui_1 | ./src/components/Data/formListing/Formlisting.js
pg_db_1 |
ui_1 | Line 49: 'mapStateToProps' is assigned a value but never used no-unused-vars
ui_1 |
pg_db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint- initdb.d/*
ui_1 | ./src/common/getFieldList.js
pg_db_1 |
ui_1 | Line 54: Expected to return a value at the end of arrow funct ion array-callback-return
ui_1 | Line 158: Expected to return a value at the end of arrow funct ion array-callback-return
pg_db_1 | waiting for server to shut down...2019-07-03 05:49:53.497 UTC [43 ] LOG: received fast shutdown request
pg_db_1 | .2019-07-03 05:49:53.499 UTC [43] LOG: aborting any active trans actions
ui_1 |
pg_db_1 | 2019-07-03 05:49:53.501 UTC [43] LOG: background worker "logical replication launcher" (PID 50) exited with exit code 1
ui_1 | ./src/common/common.js
pg_db_1 | 2019-07-03 05:49:53.508 UTC [45] LOG: shutting down
pg_db_1 | 2019-07-03 05:49:53.519 UTC [43] LOG: database system is shut do wn
ui_1 | Line 551: Expected to return a value at the end of arrow funct ion array-callback-return
pg_db_1 | done
ui_1 |
pg_db_1 | server stopped
ui_1 | ./src/components/Data/formListing/FolderList.js
pg_db_1 |
ui_1 | Line 5: Useless constructor no-useless-constructor
pg_db_1 | PostgreSQL init process complete; ready for start up.
ui_1 |
pg_db_1 |
ui_1 | ./src/components/Data/launchScreen/launchScreen.js
pg_db_1 | 2019-07-03 05:49:53.611 UTC [1] LOG: listening on IPv4 address " 0.0.0.0", port 5432
ui_1 | Line 75: 'newfolder' is assigned a value but never used no-unused-vars
pg_db_1 | 2019-07-03 05:49:53.611 UTC [1] LOG: listening on IPv6 address " ::", port 5432
ui_1 | Line 75: 'alert' is assigned a value but never used no-unused-vars
pg_db_1 | 2019-07-03 05:49:53.613 UTC [1] LOG: listening on Unix socket "/ var/run/postgresql/.s.PGSQL.5432"
ui_1 | Line 75: 'alertMessage' is assigned a value but never used no-unused-vars
pg_db_1 | 2019-07-03 05:49:53.629 UTC [61] LOG: database system was shut d own at 2019-07-03 05:49:53 UTC
ui_1 | Line 161: No duplicate props allowed react/jsx-no-duplicate-pr ops
pg_db_1 | 2019-07-03 05:49:53.635 UTC [1] LOG: database system is ready to accept connections
ui_1 | Line 167: img elements must have an alt prop, either with mean ingful text, or an empty string for decorative images jsx-a11y/alt-text
ui_1 | Line 182: img elements must have an alt prop, either with mean ingful text, or an empty string for decorative images jsx-a11y/alt-text
ui_1 | Line 191: img elements must have an alt prop, either with mean ingful text, or an empty string for decorative images jsx-a11y/alt-text
ui_1 | Line 202: img elements must have an alt prop, either with mean ingful text, or an empty string for decorative images jsx-a11y/alt-text
ui_1 |
ui_1 | Search for the keywords to learn more about each warning.
ui_1 | To ignore, add // eslint-disable-next-line to the line before.
ui_1 |
我希望能够在UI页面中创建一个新文件夹,该文件夹随后表明api服务器正在正常工作。但是很遗憾,目前我只能在浏览器中看到UI页面,无法创建一个新文件夹。