У меня есть Настройка CI Integration с AWS, все отлично работает, кроме клиента призмы, который генерируется на рабочей машине вручную. Проблема заключается в том, что сгенерированный клиент имеет адрес конечной точки http://127.0.0.1:4466
, но внутри prisma работает Docker. мне нужно вручную обновить адрес конечной точки до http://prisma:4466/
, что делается вручную. так что вся концепция CI терпит неудачу, так как мне приходится подключать сервер каждый раз, когда новое развертывание выполняется Git lab CI. есть ли способ настроить призму и запустить ее на локальном адресе, даже если он работает внутри docker.
Не работает
exports.Prisma = prisma_lib_1.makePrismaClientClass({
typeDefs,
models,
endpoint: `http://127.0.0.1:4466/truckpe/dev`,
secret: process.env.SECRET
});
Работает
exports.Prisma = prisma_lib_1.makePrismaClientClass({
typeDefs,
models,
endpoint: `http://prisma:4466/truckpe/dev`,
secret: process.env.SECRET
});
Настройка
- Docker -композиция
version: '3'
services:
server:
container_name: truckpeserver
restart: always
build: .
command: 'npm run dev'
links:
- redis
- prisma
env_file:
- ./.env
volumes:
- .:/home/node/truckpeserver/
working_dir: /home/node/truckpeserver/
ports:
- '3000:3000'
redis:
container_name: "redisserver"
image: redis:latest
restart: always
command: ["redis-server", "--bind", "redis", "--port", "6379"]
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
managementApiSecret: 1Singleshot
port: 4466
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- mysql:/var/lib/mysql
volumes:
mysql: ~
prisma.yml
# This service is based on the type definitions in the two files
# databasetypes.prisma` and `database/enums.prisma`
datamodel:
- ./packages/routes/index.directives.graphql
- ./packages/routes/index.scalar.graphql
- ./packages/routes/account/index.enum.graphql
- ./packages/routes/account/index.prisma
- ./packages/routes/panCard/index.prisma
- ./packages/routes/address/index.prisma
- ./packages/routes/drivingLicense/index.prisma
- ./packages/routes/truckpe/index.enum.graphql
- ./packages/routes/truckpe/account/index.prisma
- ./packages/routes/truckpe/brand/index.prisma
- ./packages/routes/truckpe/document/index.prisma
- ./packages/routes/truckpe/insurance/index.prisma
- ./packages/routes/truckpe/location/index.prisma
- ./packages/routes/truckpe/model/index.prisma
- ./packages/routes/truckpe/permit/index.prisma
- ./packages/routes/truckpe/rc/index.prisma
- ./packages/routes/truckpe/ride/index.enum.graphql
- ./packages/routes/truckpe/ride/index.prisma
- ./packages/routes/truckpe/fuel/index.prisma
# Generate a Prisma client in JavaScript and store in
# a folder called `generated/prisma-client`.
# It also downloads the Prisma GraphQL schema and stores it
# in `generated/prisma.graphql`.
generate:
- generator: javascript-client
output: ./prisma
# The endpoint represents the HTTP endpoint for your Prisma API.
# It encodes several pieces of information:
# * Prisma server (`localhost:4466` in this example)
# * Service name (`myservice` in this example)
# * Stage (`dev` in this example)
# NOTE: When service name and stage are set to `default`, they
# can be omitted.
# Meaning http://myserver.com/default/default can be written
# as http://myserver.com.
endpoint: 'http://127.0.0.1:4466/truckpe/dev'
# The secret is used to create JSON web tokens (JWTs). These
# tokens need to be attached in the `Authorization` header
# of HTTP requests made against the Prisma endpoint.
# WARNING: If the secret is not provided, the Prisma API can
# be accessed without authentication!
# secret: ${env.SECRET}