mcndt / noteshare.space

A service for sharing encrypted Markdown notes from Obsidian. Notes are end-to-end-encrypted and are only stored temporarily.
https://noteshare.space
MIT License
202 stars 19 forks source link

[Bug] Docker image for backend won't build #51

Open Mikle-Bond opened 1 year ago

Mikle-Bond commented 1 year ago

Describe the bug

The docker outputs this error:

------
 > [build_image 6/8] RUN npx prisma generate:
#0 5.585 Prisma schema loaded from prisma/schema.prisma
#0 7.555 Error: Get Config: Unable to establish a connection to query-engine-node-api library.
#0 7.555 Details: Unable to require(`/app/node_modules/prisma/libquery_engine-linux-musl.so.node`)
#0 7.555  Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/prisma/libquery_engine-linux-musl.so.node)
#0 7.555
#0 7.555 Prisma CLI Version : 4.2.0
------
failed to solve: process "/bin/sh -c npx prisma generate" did not complete successfully: exit code: 1                                                                                                    

I found this issue to be helpful: https://github.com/prisma/prisma/issues/9624

I managed to build the image and spin up the project by changing BUILD_IMAGE to node:14.17.1-alpine, as suggested in one of the comments.

diff --git a/server/Dockerfile b/server/Dockerfile
index 34a14c0..80a753d 100644
--- a/server/Dockerfile
+++ b/server/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:16-alpine AS BUILD_IMAGE
+FROM node:14.17.1-alpine AS BUILD_IMAGE

 # install dependencies
@@ -24,4 +24,4 @@ COPY --from=0 /app .
 ENV PORT 8080
 EXPOSE 8080

-CMD ["node", "./build/src/server.js"]
\ No newline at end of file
+CMD ["node", "./build/src/server.js"]

I find this strange, as that issue was marked as resolved back in 2021.

Environment (please complete the following information):

Client:
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.12
 Git commit:        0ed913b8-
 Built:             07/28/2020 16:36:03
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       a61e2b4
  Built:            Fri Aug  4 19:22:45 2023
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 crun:
  Version:          1.8
  GitCommit:        0356bf4aff9a133d655dc13b1d9ac9424706cac4
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
Marlon154 commented 9 months ago

@Mikle-Bond thanks alot this save my day!

RFlintstone commented 2 months ago

@Mikle-Bond Interestingly enough, I don't have this issue on FROM node:16-alpine AS BUILD_IMAGE. However I do seem to have the following:

Error: Could not find Prisma Schema that is required for this command.
You can either provide it with `--schema` argument, set it as `prisma.schema` in your package.json or put it into the default location.
Checked following paths:
schema.prisma: file not found
prisma/schema.prisma: file not found
prisma/schema: directory not found
See also https://pris.ly/d/prisma-schema-location

I'm not sure which is causing this as 'migrate' says the following:

Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "db.sqlite" at "file:/database/db.sqlite"
11 migrations found in prisma/migrations
No pending migrations to apply.

Seemingly without any apply history. (I'm trying to run it on a K3S cluster so it's definitely possible that, that's the issue.)