Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't create svg with Docker (Debian) #28

Closed
mshige1979 opened this issue Nov 25, 2021 · 5 comments
Closed

I can't create svg with Docker (Debian) #28

mshige1979 opened this issue Nov 25, 2021 · 5 comments

Comments

@mshige1979
Copy link

mshige1979 commented Nov 25, 2021

What do you need to create in Debian or Ubuntu?

Docker Image:node:16
https://hub.docker.com/layers/node/library/node/16/images/sha256-1d35d3b639b639fb55d955d271c1da97d9e730c7dc0b9bae352a63c50b7c12c1?context=explore

package.json

{
  "name": "app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "ts-node-dev --respawn --debug --exit-child src/index.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@prisma/client": "^3.5.0",
    "@types/express": "^4.17.13",
    "@types/node": "^16.11.9",
    "express": "^4.17.1",
    "mermaid.cli": "^0.5.1",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.2"
  },
  "devDependencies": {
    "prisma": "^3.5.0",
    "prisma-erd-generator": "^0.6.1",
    "ts-node-dev": "^1.1.8"
  },
  "prisma": {
    "seed": "ts-node prisma/seed.ts"
  }
}

schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator erd {
  provider = "prisma-erd-generator"
  output   = "./ERD.svg"
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  age   Int?

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")

  profile Profile?
  posts   Post[]

  @@map("users")
}

model Profile {
  id       Int    @id @default(autoincrement())
  nickName String @map("nick_name")

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")

  userId Int  @unique
  user   User @relation(fields: [userId], references: [id])

  @@map("profile")
}

model Post {
  id    Int    @id @default(autoincrement())
  title String @map("title")
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @map("updated_at")
  
  userId Int
  user   User @relation(fields: [userId], references: [id])

  @@map("posts")
}
@keonik
Copy link
Owner

keonik commented Nov 25, 2021

It shouldn’t be anything different. The only thing OS dependent is the prisma engine.

@keonik
Copy link
Owner

keonik commented Nov 25, 2021

We even do a smoke test to check all the OS on a new PR. ubuntu 15

@keonik
Copy link
Owner

keonik commented Nov 25, 2021

const queryEngine =
if you fork the repo and want to see if it runs locally log out that line and it should show you what engine you’re running. The only new thing I could see affecting your no output would be Docker. I’m not sure if we have had people running prisma generate yet in docker. As long as your directories are mapped to write the new ER.svg to a path you shouldn’t see that problem.

@mshige1979
Copy link
Author

It seems that there was an error in mmdc.
I recreated a new dockerfile and ran it and it worked.

dockerFile

# base
FROM node:16

# shell
SHELL ["/bin/bash", "-c"]

# env
ENV TZ Asia/Tokyo
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

# apt update
RUN apt update && \
    apt-get update -qq && \
    apt-get install -y autoconf sudo wget unzip curl vim bzip2 build-essential bison git tzdata cmake

# lib
RUN apt-get install -y \
    libnss3 libatk1.0-0 libatk-bridge2.0-0 \
    libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 \
    libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 \
    libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 \
    libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 \
    libxcb1 libxcomposite1 libxcursor1 libxdamage1 \
    libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \
    libxss1 libxtst6 ca-certificates fonts-liberation \
    libappindicator1 libnss3 libdrm-dev libdrm2 \
    libgbm-dev libgbm1 libasound2 libasound2-dev libxshmfence1 libxshmfence-dev && \
    apt-get clean && \
    rm -rf /var/cache/apt

# ユーザーを作成
RUN useradd -m app
RUN echo 'app:ampassword' |chpasswd
RUN echo "app ALL=NOPASSWD: ALL" >> /etc/sudoers
USER app

# ホームディレクトリ及び作業ディレクトリ設定
ENV HOME /home/app
RUN mkdir -p $HOME/backend
WORKDIR /home/app/backend

build

docker-compose build
docker-compose up -d
docker-compose run --rm backend npx prisma generate

@mshige1979
Copy link
Author

ERD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants