Peppermint-Lab / peppermint

An open source ticket management & help desk solution. A zendesk/freshdesk alternative
https://peppermint.sh
Other
1.76k stars 179 forks source link

Issue logging into from external device #150

Closed Ethan7678 closed 7 months ago

Ethan7678 commented 1 year ago

So I run "sudo docker-compose up -d " to start peppermint then I can connect to if through localhost:5000 or 172.71.71.1:5000*. Then from there I try to login and It let's me from the host but not externally so I try "sudo docker run -p 5001:5001 pepperlabs/peppermint" and the console just say's this back.

yarn run v1.22.19
$ prisma migrate deploy
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "peppermint", schema "public" at "localhost:5432"

Error: P1001: Can't reach database server at `localhost`:`5432`

Please make sure your database server is running at `localhost`:`5432`.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any help would be nice thanks.

void4121 commented 1 year ago

Hi Ethan7678,

I had a very similar issue. I am hosting my docker on a Proxmox server so I cant access the container from another machine. I changed the 'localhost' to the container IP in the YML file and kept every other config the same and now its working. I was even able to point it to Cloudflare to run the services out my network and it works great!

ref: https://github.com/Peppermint-Lab/peppermint/issues/146

Ethan7678 commented 1 year ago

Hi thanks so just to confirm to get the IP address of the container I do this command and get this from the console and from this I get the IP 172.20.0.3 I'm assuming this is the correct IP so I change my .yml to get this (code at the bottom) but this does not work with my public IP (to clarify my LAN connection works)

~/peppermint$ docker inspect \
> docker inspect \
> peppermint
[
    {
        "Id": "0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad",
        "Created": "2023-06-25T18:08:10.571951248Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "/bin/sh",
            "-c",
            "bash -C './start.sh';'bash'"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 21767,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-06-25T19:12:58.476258383Z",
            "FinishedAt": "2023-06-25T19:12:47.952444938Z"
        },
        "Image": "sha256:959eb45041cab4723381b50d3f136255f11a6b89abc3473034a0e93968e017ab",
        "ResolvConfPath": "/var/lib/docker/containers/0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad/hostname",
        "HostsPath": "/var/lib/docker/containers/0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad/hosts",
        "LogPath": "/var/lib/docker/containers/0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad/0716ec54f36dc31b0bb39222ae19b5bc60a011b7c0d3a76ab36685ed36846aad-json.log",
        "Name": "/peppermint",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": [
            "6ba09dc2d7851b3f193a2dc5d5a1d3d53b2d3d9b5a75976476790ed2e1a8a2f5"
        ],
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "peppermint_default",
            "PortBindings": {
                "5000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5000"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "on-failure",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "ConsoleSize": [
                0,
                0
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/4b65560e3353069462ab099347f9e6e300b77cd9addee8fc48056ddf16e337f5-init/diff:/var/lib/docker/overlay2/0d5e5b77d83b599fbd6223b9c1600a788a31dabe65765835bde01e65d2bd6c78/diff:/var/lib/docker/overlay2/90c6aa082869947218ec4a6ea1c673050292e93a7fdb8d1c4f5b16043d679001/diff:/var/lib/docker/overlay2/29638ea1c2c31c8f07f3359ef45b961a044a0c54619d392bb1de02bc9fb38e8b/diff:/var/lib/docker/overlay2/7914e9da97d5b5acc0ffbab5f1e2a602dccd154cc9cc07dc7d29f9ff8529e7c3/diff:/var/lib/docker/overlay2/14de5b7c73a9a635604b7dea4c62b4242343fe0d3848fdb178195ecf00f400be/diff:/var/lib/docker/overlay2/aed793b8ab5fa630db9b00846f7a8356708502df29b41e82154222e6b3326e7f/diff:/var/lib/docker/overlay2/ff8b892f16ffef12da7ade68f228df7b21efbb2b177d527e93d76b87c18e3a65/diff:/var/lib/docker/overlay2/5f2a1ddad57d0dc8bc9ea9242c9783b416434ed389f766c18bf695c9f79240ca/diff:/var/lib/docker/overlay2/b584c5a2fd924082f69abcc38b1d5b27c8966ce19bbd999aa2880c0fa6e26495/diff:/var/lib/docker/overlay2/9b7a84a987a1ee5ef5e2f3b3a327935e16c1c99ec73690767c8603a899b35914/diff:/var/lib/docker/overlay2/c9aebfded0286a5bf5d7fdf823b682ab1c53c3b5e5978333f7050eb40c3c05cc/diff:/var/lib/docker/overlay2/4801da5a51dd61bd419e86cb0d5a58668966baaab91b87ce739f7aa0835ba62c/diff:/var/lib/docker/overlay2/1513571075d8668a86e3cfe88c1eea1cf4710ced5b96fbcc2f7d331abf084203/diff:/var/lib/docker/overlay2/7e4aef6214d5a5e3dfe91d453c09fa6eb9833aea0477997ab6d438377ca6dc11/diff:/var/lib/docker/overlay2/aa012f11f93c36945363060b27fef94d09a8f3035fe1c62d91d124b05da249fd/diff:/var/lib/docker/overlay2/a0faec8ed7e0196bd7002795783e26d2935e9f45eddfeedb2aa902feef1d5345/diff:/var/lib/docker/overlay2/255f61e3b6b846e0767db89201bfb543003ab72127b6becd8a8efe500f06a5a6/diff",
                "MergedDir": "/var/lib/docker/overlay2/4b65560e3353069462ab099347f9e6e300b77cd9addee8fc48056ddf16e337f5/merged",
                "UpperDir": "/var/lib/docker/overlay2/4b65560e3353069462ab099347f9e6e300b77cd9addee8fc48056ddf16e337f5/diff",
                "WorkDir": "/var/lib/docker/overlay2/4b65560e3353069462ab099347f9e6e300b77cd9addee8fc48056ddf16e337f5/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "0716ec54f36d",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5000/tcp": {},
                "5001/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PORT=5000",
                "DB_USERNAME=peppermint",
                "DB_PASSWORD=1234",
                "DB_HOST=postgres",
                "BASE_URL=192.168.8.52:5000",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=14.19.3",
                "YARN_VERSION=1.22.19",
                "NODE_ENV=production"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "bash -C './start.sh';'bash'"
            ],
            "Image": "pepperlabs/peppermint:latest",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "5a5a8face089cdb6c79ef0c68c5fba2db420c7c933130a6cae3046ff22023692",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "peppermint",
                "com.docker.compose.project.config_files": "docker-compose.yml",
                "com.docker.compose.project.working_dir": "/home/ethan747/peppermint",
                "com.docker.compose.service": "client",
                "com.docker.compose.version": "1.29.2",
                "desktop.docker.io/wsl-distro": "Ubuntu-22.04"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "b046b542d78d5e456d1e09faed574c3aa450260469bdb6531ee112bd9b83e6f9",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "5000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5000"
                    }
                ],
                "5001/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/b046b542d78d",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "peppermint_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "client",
                        "0716ec54f36d"
                    ],
                    "NetworkID": "888f8b5b89a6a0b09391fa3cbb92db850f3fdf1570da6779f4a496d1787b1172",
                    "EndpointID": "455a6a3dcfeb473d0a93c68a9c6ff0a4f2136270b0e003500a2061ef2111a55a",
                    "Gateway": "172.20.0.1",
                    "IPAddress": "172.20.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:14:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]
Error: No such object: docker
Error: No such object: inspect

2.

  GNU nano 6.2                                              docker-compose.yml                                                       version: "3.1"

services:
  postgres:
    container_name: postgres
    image: postgres:latest
    restart: always
    volumes:
      - ./docker-data/db:/data/db
    environment:
      POSTGRES_USER: peppermint
      POSTGRES_PASSWORD: 1234
      POSTGRES_DB: peppermint

  client:
    container_name: peppermint
    image: pepperlabs/peppermint:latest
    ports:
      - 5000:5000
    restart: on-failure
    depends_on:
      - postgres
    environment:
      PORT: 5000
      DB_USERNAME: peppermint
      DB_PASSWORD: 1234
      DB_HOST: 'postgres'
      BASE_URL: "172.20.0.3:5000"
void4121 commented 1 year ago

Thanks for posting the config that helps a lot, however I have to ask are you planning on using this outside your network?

I see the IP is a private IP address if so I recommend removing the port, shutting down all instances of this container and rerunning

The 'BASE_URL' as once you access the IP it might redirect to the Localhost IP and port (which may not permit access)

Here is a version I am currently running (bare in mind I am using 'Zero Trust' through Cloudflare so I have the URL redacted)

` services: postgres: container_name: postgres image: postgres:latest restart: always volumes:

`

void4121 commented 1 year ago

to clarify my LAN connection works

You can access the server via another machine? You just cant access from another network?

What are you running this service on? And how are you trying to access it? Via a domain?

If thtats the case I think the YML I provided would be the best fit if you run a reverse proxy on it like CloudFlare

Ethan7678 commented 1 year ago

Cool thanks and sorry yes Me and my Dad ran some tests to see what was going on and we can get the Login page working but after it cut's the connection and sorry I meant localhost not LAN.

It is a Windows PC running docker-desktop with WSL-2 Ubuntu 22.04.2 LTS as the command line interface and I'm looking at publishing it to my LAN so other devices can connect which I should have clarified.

I am trying to access it through It's Local IP but could try a domain.

void4121 commented 1 year ago

I had the same issue more than likely its trying to access the internal port when it doesnt have access

Remove ':5000' from the following line in your YML: BASE_URL: "172.20.0.3:5000"

If its internal switching it to: BASE_URL: "172.20.0.3" and composing the file again should work

If you try to access it via domain create a Cloudflare account and register a domain. From there you can use 'ZeroTrust' to run a reverse proxy on the peppermint container

REALLY IMPORTANT!!! Make sure when you run 'docker-compose up -d' you rm all instances of the previous container and verify by running 'docker ps' to make sure no containers are running Then you can try and compose the file with the modified version

Ethan7678 commented 1 year ago

So I've done what you said and removed any active Peppermint Containers and it still start's the server on "0.0.0.0:5000, url: http://localhost:5000" as seen in the command line below.

I'm quite stumped as what to do at this point because people say to add the port to login and that is what happens I can't login now but It still load's up the login page but with the port specified it works fine on the local host no outside devices on the LAN can access the site past the login.

here Is the command line when booting with new .yml file.

2023-06-28 18:55:02 yarn run v1.22.19
2023-06-28 18:55:02 $ prisma migrate deploy
2023-06-28 18:55:02 Environment variables loaded from .env
2023-06-28 18:55:02 Prisma schema loaded from prisma/schema.prisma
2023-06-28 18:55:02 Datasource "db": PostgreSQL database "peppermint", schema "public" at "postgres:5432"
2023-06-28 18:55:02 
2023-06-28 18:55:02 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2023-06-28 18:55:10 yarn run v1.22.19
2023-06-28 18:55:10 $ prisma migrate deploy
2023-06-28 18:55:10 Environment variables loaded from .env
2023-06-28 18:55:10 Prisma schema loaded from prisma/schema.prisma
2023-06-28 18:55:10 Datasource "db": PostgreSQL database "peppermint", schema "public" at "postgres:5432"
2023-06-28 18:55:10 
2023-06-28 18:55:10 3 migrations found in prisma/migrations
2023-06-28 18:55:10 
2023-06-28 18:55:11 Applying migration `20220129233509_`
2023-06-28 18:55:11 Applying migration `20220130122101_`
2023-06-28 18:55:11 Applying migration `20220130225732_`
2023-06-28 18:55:11 
2023-06-28 18:55:11 The following migrations have been applied:
2023-06-28 18:55:11 
2023-06-28 18:55:11 migrations/
2023-06-28 18:55:11   └─ 20220129233509_/
2023-06-28 18:55:11     └─ migration.sql
2023-06-28 18:55:11   └─ 20220130122101_/
2023-06-28 18:55:11     └─ migration.sql
2023-06-28 18:55:11   └─ 20220130225732_/
2023-06-28 18:55:11     └─ migration.sql
2023-06-28 18:55:11       
2023-06-28 18:55:11 All migrations have been successfully applied.
2023-06-28 18:55:11 Done in 1.45s.
2023-06-28 18:55:11 yarn run v1.22.19
2023-06-28 18:55:11 $ prisma generate
2023-06-28 18:55:12 Environment variables loaded from .env
2023-06-28 18:55:12 Prisma schema loaded from prisma/schema.prisma
2023-06-28 18:55:16 
2023-06-28 18:55:16 ✔ Generated Prisma Client (3.7.0 | library) to ./node_modules/@prisma/client in 191ms
2023-06-28 18:55:16 You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
2023-06-28 18:55:16 ```
2023-06-28 18:55:16 import { PrismaClient } from '@prisma/client'
2023-06-28 18:55:16 const prisma = new PrismaClient()
2023-06-28 18:55:16 ```
2023-06-28 18:55:16 
2023-06-28 18:55:16 warn Versions of prisma@3.14.0 and @prisma/client@3.7.0 don't match.
2023-06-28 18:55:16 This might lead to unexpected behavior.
2023-06-28 18:55:16 Please make sure they have the same version.
2023-06-28 18:55:16 Done in 5.22s.
2023-06-28 18:55:17 yarn run v1.22.19
2023-06-28 18:55:17 $ prisma db seed
2023-06-28 18:55:17 Environment variables loaded from .env
2023-06-28 18:55:17 Running seed command `node prisma/seed.js` ...
2023-06-28 18:55:18 {
2023-06-28 18:55:02 Error: P1001: Can't reach database server at `postgres`:`5432`
2023-06-28 18:55:02 
2023-06-28 18:55:02 Please make sure your database server is running at `postgres`:`5432`.
2023-06-28 18:55:02 error Command failed with exit code 1.
2023-06-28 18:55:16 ┌─────────────────────────────────────────────────────────┐
2023-06-28 18:55:16 │  Update available 3.14.0 -> 4.16.1                      │
2023-06-28 18:55:16 │                                                         │
2023-06-28 18:55:16 │  This is a major update - please follow the guide at    │
2023-06-28 18:55:16 │  https://pris.ly/d/major-version-upgrade                │
2023-06-28 18:55:16 │                                                         │
2023-06-28 18:55:16 │  Run the following to update                            │
2023-06-28 18:55:16 │    yarn add --dev prisma@latest                         │
2023-06-28 18:55:16 │    yarn add @prisma/client@latest                       │
2023-06-28 18:55:16 └─────────────────────────────────────────────────────────┘
2023-06-28 18:55:19 warn  - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled
2023-06-28 18:55:18   admin: {
2023-06-28 18:55:18     id: 1,
2023-06-28 18:55:18     createdAt: 2023-06-28T17:55:18.181Z,
2023-06-28 18:55:18     updatedAt: 2023-06-28T17:55:18.181Z,
2023-06-28 18:55:18     name: 'admin',
2023-06-28 18:55:18     password: '$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu',
2023-06-28 18:55:18     email: 'admin@admin.com',
2023-06-28 18:55:18     isAdmin: true
2023-06-28 18:55:18   },
2023-06-28 18:55:18   internal: {
2023-06-28 18:55:18     id: 1,
2023-06-28 18:55:18     createdAt: 2023-06-28T17:55:18.190Z,
2023-06-28 18:55:18     updatedAt: 2023-06-28T17:55:18.190Z,
2023-06-28 18:55:18     name: 'internal',
2023-06-28 18:55:18     email: 'internal@admin.com',
2023-06-28 18:55:18     contactName: 'admin',
2023-06-28 18:55:18     number: '123456789',
2023-06-28 18:55:18     notes: null
2023-06-28 18:55:18   }
2023-06-28 18:55:18 }
2023-06-28 18:55:18 
2023-06-28 18:55:18 🌱  The seed command has been executed.
2023-06-28 18:55:18 Done in 1.43s.
2023-06-28 18:55:18 yarn run v1.22.19
2023-06-28 18:55:18 $ next start
2023-06-28 18:55:18 ready - started server on 0.0.0.0:5000, url: http://localhost:5000
2023-06-28 18:55:18 info  - Loaded env from /app/.env

Thank you for your time with helping.

Ethan7678 commented 1 year ago

Here is my Docker Containers for Peppermint running

Screenshot 2023-06-28 190511
void4121 commented 1 year ago

when you go to localhost on a seperate machine it isnt running any services. Its important to put just the IP no port no local host.

imagine localhost as a home for a particular machine

so if you are 172.0.0.1 running a webserver on LOCALhost

172.0.0.2 may not be able to connect to it because they have seperate localhosts

Thats the easier way I can think of it

Youre base url should look like:

BASE_URL: "172.20.0.3"

Copy of my forked/modified repo

Ethan7678 commented 1 year ago

Sorry I should have specified I did everything in your last message about what the file should look like remove containers and change the BASE_URL: which has been since that message 172.20.0.3 but it sill pulls up as localhost in CMD and I put that in the browser but It won't pull anything up (this is on the host machine) the localhost part made sense as yeah to devices have different localhosts but without the port I cannot connect to it and when I do that I then can't login and I just tried your forked version of the .yml file and it doesn't even start at all

potts99 commented 7 months ago

This should be a non issue going forward with the removal of nex-auth :)