Coder Social home page Coder Social logo

Comments (20)

kelvinalfaro avatar kelvinalfaro commented on June 6, 2024 2

I removed the single and double quotes didn't help.
Any other way to resolved this?

from docker.

krumware avatar krumware commented on June 6, 2024 2

Ah, must have left that in there while trying things. I've been working on this locally today, I'll see if I can clean it up

from docker.

f95f706a avatar f95f706a commented on June 6, 2024 1

Same thing here. I mounted schema.prisma via docker-compose to override the default one at /app/prisma/schema.prisma

 volumes:
      - ./schema.prisma:/app/prisma/schema.prisma

By the way, did you notice that /bin/sh on Calendso instance is not working. Docker exec spits back to the terminal without errors.

from docker.

krumware avatar krumware commented on June 6, 2024 1

I've been seeing that as well. This won't be a final solution anyways, however, because we won't want to use yarn dev in production. I'll typically move yarn dev to command in the docker-compose file, and how how to mount a local volume for using docker-compose for development. Still working on a proper prod build and have notes on some of the other threads.

@vanceism7 I have that JWT_SECRET included in mine after copying some extras from calendso/calendso while debugging. good pointer!

from docker.

krumware avatar krumware commented on June 6, 2024 1

To come back to this for those watching. On the latest version, the docker image appears to build and run just fine, but there are some of the same issues in dwrb's comment above with the absolute URL stuff (that's next.js related)

But for this issue, in some cases docker-compose doesn't like combining variables within the .env file
(such as DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB})
but if you add the same environmental variable to the docker-compose.yml, then it will combine those and take precedent over the variable in the .env file.

  calendso:
    build: .
    restart: always
    ports:
      - 3000:3000
      - 5555:5555
    env_file: .env
    environment:
      - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB}
    depends_on:
      - db

without:

calendso_1  | Prisma schema loaded from prisma/schema.prisma
calendso_1  | Datasource "db": PostgreSQL database "$%7BPOSTGRES_DB%7D", schema "public" at "${DATABASE_HOST}:5432"
calendso_1  | Error: Migration engine error:
calendso_1  | [libs/datamodel/core/src/ast/parser/parse_expression.rs:88:18] internal error: entered unreachable code: Encountered impossible string content during parsing: Pair { rule: string_interpolate_escape, span: Span { str: "${POSTGRES_USER}", start: 105, end: 121 }, inner: [Pair { rule: expression, span: Span { str: "POSTGRES_USER", start: 107, end: 120 }, inner: [Pair { rule: constant_literal, span: Span { str: "POSTGRES_USER", start: 107, end: 120 }, inner: [] }] }] }
calendso_1  | + yarn start
calendso_1  | yarn run v1.22.15
calendso_1  | $ next start
calendso_1  | ready - started server on 0.0.0.0:3000, url: http://localhost:3000

with:

calendso_1  | Prisma schema loaded from prisma/schema.prisma
calendso_1  | Datasource "db": PostgreSQL database "calendso", schema "public" at "db:5432"
calendso_1  | 
calendso_1  | 39 migrations found in prisma/migrations
calendso_1  | 
calendso_1  | No pending migrations to apply.
calendso_1  | + yarn start
calendso_1  | yarn run v1.22.15
calendso_1  | $ next start
calendso_1  | ready - started server on 0.0.0.0:3000, url: http://localhost:3000

from docker.

krumware avatar krumware commented on June 6, 2024

The single/double quotes must be removed from the .env file in order for this to work properly. Docker doesn't respect them in the env files.

working example: (I added POSTGRES_HOST for better capability with start.sh)

DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}

This also affects the GOOGLE_API_CREDENTIALS, the json object must not be wrapped in quotes or else the variable is interpreted as '{}'

With single quotes:

warn  - Disabled 'Google Calendar' integration. Reason: Invalid value for GOOGLE_API_CREDENTIALS environment variable. When set, this value needs to contain valid JSON like {"web":{"client_id":"<clid>","client_secret":"<secret>","redirect_uris":["<yourhost>/api/integrations/googlecalendar/callback>"]}. You can download this JSON from your OAuth Client @ https://console.cloud.google.com/apis/credentials.

Tested on Docker Desktop 4.1 in WSL
https://dev.to/tvanantwerp/don-t-quote-environment-variables-in-docker-268h

from docker.

agapejon avatar agapejon commented on June 6, 2024

same issue, removed the quotes but still getting the same error

from docker.

krumware avatar krumware commented on June 6, 2024

@kelvinalfaro @agapejon does anything change if you use yarn dev instead of yarn start?

also, I did some significant rework of the dockerfile, since I had other issues with the use of yarn build that I haven't pushed through yet. yarn build is likely generating static files at docker build time, which wont include the .env variables used by docker-compose. yarn dev should support runtime compile with env vars.

FROM node:14-alpine as deps

RUN apk add --no-cache libc6-compat
RUN mkdir app
COPY calendso/package.json calendso/yarn.lock /app/
COPY calendso/prisma /app/prisma
WORKDIR /app
RUN ls
RUN yarn install

FROM node:14-alpine as builder
COPY calendso /app
COPY --from=deps /app/node_modules /app/node_modules
WORKDIR /app
# RUN yarn install

FROM node:14-alpine as runner
ENV NODE_ENV production

# copy all files
COPY --from=builder /app /app
COPY .env /app/.env
# COPY --from=builder /app/next.config.js ./
# COPY --from=builder /app/public ./public
# COPY --from=builder /app/.next ./.next
# COPY --from=builder /app/node_modules ./node_modules
# COPY --from=builder /app/package.json ./package.json
# COPY --from=builder /app/prisma ./prisma
COPY  scripts /app/scripts
WORKDIR /app
EXPOSE 3000
CMD ["/app/scripts/start.sh"]

(disclaimer, this dockerfile can be much more efficient, but I reworked some things for my own clarity while debugging)

from docker.

kelvinalfaro avatar kelvinalfaro commented on June 6, 2024

Thanks. This worked well. Though I gave up on it for now. Once it deployed, i was unable to set up the database. Maybe will try again soon. Your response was really appreciated however.

from docker.

krumware avatar krumware commented on June 6, 2024

That may be a combination with my other issue posted. I'll get a WIP branch up to try early this week

from docker.

vanceism7 avatar vanceism7 commented on June 6, 2024

@krumware Trying the new Dockerfile got me further in the process, but I get this error when running
sudo docker-compose up --build

error:

Error: Could not find a production build in the '/app/.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id

Adding yarn build into the start.sh script got the app to run successfully, but not sure if that's really the proper thing to do here

from docker.

krumware avatar krumware commented on June 6, 2024

Can you also by chance try yarn dev instead of yarn build in the start file?

from docker.

vanceism7 avatar vanceism7 commented on June 6, 2024

Ah, yea, using the new dockerfile you provided + changing yarn start to yarn dev in scripts/start.sh got it working. Thanks!

from docker.

vanceism7 avatar vanceism7 commented on June 6, 2024

Ah wait, nvm. If I replace yarn start with yarn dev - docker-compose successfully starts the app, but then the app doesn't actually work. The website spews the following error:

TypeError: (0 , react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV) is not a function

Naively searching for that error online, I found this
vercel/next.js#26983

Keeping yarn start and adding yarn build the line before seems to avoid this error

from docker.

krumware avatar krumware commented on June 6, 2024

great extra note, I saw that before and added NODE_ENV=development to my local .env, which fixed that. But I missed adding that here.

Can you please try that? add NODE_ENV=development to your .env file then try yarn dev as before?

from docker.

vanceism7 avatar vanceism7 commented on June 6, 2024

Just tried it - its working!

Just a note, the app is getting stuck on the log-in screen, but since this is unrelated to this issue in particular, I'll create a new issue for this. Thanks again for your help

Ok, just for posterity, this login hanging issue seems to be stemming from a new environmental variable requirement.
We now need to add to our .env file a variable: JWT_SECRET=b6182e2660addf13ec964a5c512c2f5d35d52da8

https://github.com/calendso/calendso/issues/760

from docker.

drwb avatar drwb commented on June 6, 2024

I've been following along and this evening went through these steps (Replaced Dockerfile, added NODE_ENV=development, changed yarn start to yarn dev) and we get to the following, and it then hangs:
Screenshot 2021-10-05 at 23 28 00

although it seems hitting the container on :3000 triggers the JIT compilation and throws this error:
Screenshot 2021-10-05 at 23 28 13

It feels like we're nearly there.

from docker.

drwb avatar drwb commented on June 6, 2024

Thanks @krumware I’ll give it a go this weekend.

from docker.

krumware avatar krumware commented on June 6, 2024

Sounds good! please see #37

from docker.

killjoy2013 avatar killjoy2013 commented on June 6, 2024

The single/double quotes must be removed from the .env file in order for this to work properly. Docker doesn't respect them in the env files.

working example: (I added POSTGRES_HOST for better capability with start.sh)

DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}

This also affects the GOOGLE_API_CREDENTIALS, the json object must not be wrapped in quotes or else the variable is interpreted as '{}'

With single quotes:

warn  - Disabled 'Google Calendar' integration. Reason: Invalid value for GOOGLE_API_CREDENTIALS environment variable. When set, this value needs to contain valid JSON like {"web":{"client_id":"<clid>","client_secret":"<secret>","redirect_uris":["<yourhost>/api/integrations/googlecalendar/callback>"]}. You can download this JSON from your OAuth Client @ https://console.cloud.google.com/apis/credentials.

Tested on Docker Desktop 4.1 in WSL https://dev.to/tvanantwerp/don-t-quote-environment-variables-in-docker-268h

Thank you :-)

from docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.