Giter VIP home page Giter VIP logo

docker's Introduction

Spacebar Server Docker

GitHub: Spacebar Docker GitHub

Dev environment

To run it you need docker and docker-compose sudo docker compose up or sudo docker compose up -d

docker-compose.yaml

version: "3.9"
services:
  spacebar:
    image: spacebarchat/server:latest-sqlite
    ports:
      - "3001:3001"
    volumes:
      - spacebar-database:/exec/persistent/database/
      - spacebar-storage:/exec/persistent/storage
    environment:
      DATABASE: "/exec/persistent/database/database.db"
      STORAGE_PROVIDER: "file"
      STORAGE_LOCATION: "/exec/persistent/storage/"
      PORT: "3001"
volumes:
  spacebar-database:
  spacebar-storage:

Prod environment with local file storage or with S3

Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD):

export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DATABASE=spacebar

docker-compose.prod.yaml

version: "3.9"
services:
  spacebar:
    image: spacebarchat/server:latest-postgressql
    restart: unless-stopped
    ports:
      - "3001:3001"
    volumes:
      - spacebar-storage:/exec/persistent/storage
    environment:
      DATABASE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
      STORAGE_PROVIDER: "file"
      STORAGE_LOCATION: "/exec/persistent/storage/"
      PORT: "3001"
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER:?err}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?err}
      - POSTGRES_DB=${POSTGRES_DATABASE:?err}
    ports:
      - '127.0.0.1:5432:5432'
    volumes: 
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DATABASE} -U ${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  spacebar-storage:
  db:

To run it you need docker and docker-compose sudo docker-compose -f docker-compose.prod.yaml up or sudo docker-compose -f docker-compose.prod.yaml up -d

Additional you can set S3 storage backend:

export S3_BUCKET=S3://...
export S3_BUCKET_NAME=test
export S3_BUCKET_REGION=eu-central-1

docker-compose.prod.s3.yaml

version: "3.9"
services:
  spacebar:
    image: spacebarchat/server:latest-postgressql
    restart: unless-stopped
    ports:
      - "3001:3001"
    environment:
      DATABASE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
      STORAGE_PROVIDER: s3
      STORAGE_LOCATION: ${S3_BUCKET:?err}
      STORAGE_BUCKET: ${S3_BUCKET_NAME:?err}
      STORAGE_REGION: ${S3_BUCKET_REGION:?err}
      PORT: "3001"
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DATABASE}
    ports:
      - '127.0.0.1:5432:5432'
    volumes: 
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DATABASE} -U ${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  db:

Then start it with: docker-compose -f docker-compose.prod.s3.yaml up or docker-compose -f docker-compose.prod.s3.yaml up -d

At first start, you get the following error. This error can be ignored due to first start.

db_1        | 2023-03-04 17:28:25.790 UTC [63] ERROR:  relation "config" does not exist at character 31
db_1        | 2023-03-04 17:28:25.790 UTC [63] STATEMENT:  SELECT COUNT(1) AS "cnt" FROM "config" "ConfigEntity"

With NGINX and client (Which is under WIP)

Under spacebar-server-client-proxy there is a small project in experimental state. Which run the spacebar server, the spacebar client with an reverse proxy and ssl in it. You need to clone the repo. git clone https://github.com/spacebarchat/docker.git And then go to spacebar-server-client-proxy Please adapt the following env variables to your need:

export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=your-password
export POSTGRES_DATABASE=spacebar
export MAIL_CERTBOT=your-email
export NGINX_HOST=your-domain

To run it you need docker and docker-compose sudo docker-compose -f docker-compose.prod.yaml up or sudo docker-compose -f docker-compose.prod.yaml up -d

Spacebar client

Due to the fact that it is under development for now, i provide no client README. It may change in the future. Take a look at the With NGINX and client (Which is under WIP) section

docker's People

Contributors

casraw avatar dependabot[bot] avatar diegomagdaleno avatar maddyunderstars avatar puyodead1 avatar thearcanebrony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker's Issues

bug: error An unexpected error occurred

Maybe someone deleted this project.
Snipaste_2023-08-07_23-50-19

[+] Building 34.5s (17/18)
 => [internal] load .dockerignore                                                                                                                                                                           0.1s
 => => transferring context: 2B                                                                                                                                                                             0.0s
 => [internal] load build definition from Dockerfile-frontend                                                                                                                                               0.2s
 => => transferring dockerfile: 906B                                                                                                                                                                        0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                 19.2s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                                             0.0s
 => [internal] load metadata for docker.io/library/nginx:alpine                                                                                                                                             8.7s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                                                                             7.8s
 => [internal] load build context                                                                                                                                                                           0.1s
 => => transferring context: 39B                                                                                                                                                                            0.0s
 => [builder 1/9] FROM docker.io/library/ubuntu:22.04@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508                                                                               0.0s
 => CACHED [stage-1 1/2] FROM docker.io/library/nginx:alpine@sha256:2d194184b067db3598771b4cf326cfe6ad5051937ba1132b8b7d4b0184e0d0a6                                                                        0.0s
 => CACHED [builder 2/9] RUN apt update ; apt install -y curl git gnupg2 ;                                                                                                                                  0.0s
 => CACHED [builder 3/9] RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -                                                                                                              0.0s
 => CACHED [builder 4/9] RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list                                                                                  0.0s
 => CACHED [builder 5/9] RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -                                                                                                                        0.0s
 => CACHED [builder 6/9] RUN apt update ; apt install -y yarn nodejs                                                                                                                                        0.0s
 => CACHED [builder 7/9] RUN git clone https://github.com/Casraw/spacebarchat-client.git ; cd spacebarchat-client ; git checkout master                                                                     0.0s
 => CACHED [builder 8/9] COPY script-frontend.sh spacebarchat-client/script-frontend.sh                                                                                                                     0.0s
 => ERROR [builder 9/9] RUN cd spacebarchat-client && chmod +x script-frontend.sh &&  sed -i -e 's/\r$//' script-frontend.sh && ./script-frontend.sh && yarn install && yarn build:web                      5.9s
------
 > [builder 9/9] RUN cd spacebarchat-client && chmod +x script-frontend.sh &&  sed -i -e 's/\r$//' script-frontend.sh && ./script-frontend.sh && yarn install && yarn build:web:
#0 0.862 yarn install v1.22.19
#0 0.953 [1/4] Resolving packages...
#0 5.724 error An unexpected error occurred: "https://registry.yarnpkg.com/@puyodead1%2ffosscord-api-types: Not found".
#0 5.725 info If you think this is a bug, please open a bug report with the information provided in "/spacebarchat-client/yarn-error.log".
#0 5.725 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
failed to solve: process "/bin/sh -c cd spacebarchat-client && chmod +x script-frontend.sh &&  sed -i -e 's/\\r$//' script-frontend.sh && ./script-frontend.sh && yarn install && yarn build:web" did not complete successfully: exit code: 1

Seeking guidance on redirect loop issue with modified docker-compose.prod.yaml

I apologize for reaching out with a question that may not directly contribute to software improvement or bug fixes. I understand that the issue I'm encountering is likely due to modifications I made to the original compose file, rather than a problem with the repository itself.

On my server, I have several services whose ports are set up to forward requests from port 443 to containers via Caddy. As a result, I had to replace the nginx setup provided in the compose file with a configuration that works with the Caddy instance I had previously installed.

Here is my modified docker-compose.prod.yaml file:

version: "3.9"

services:
  spacebar:
    build:
      context: .
      dockerfile: Dockerfile-prod
    restart: unless-stopped
    ports:
      - "3001:3001"
    volumes:
      - spacebar-storage:/exec/persistent/storage
    environment:
      DATABASE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
      STORAGE_PROVIDER: "file"
      STORAGE_LOCATION: "/exec/persistent/storage/"
      PORT: "3001"
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER:?err}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?err}
      - POSTGRES_DB=${POSTGRES_DATABASE:?err}
    ports:
      - '127.0.0.1:5432:5432'
    volumes: 
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DATABASE} -U ${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  spacebar-client:
    build:
      context: .
      dockerfile: Dockerfile-frontend
      args:
        - SERVER_URL=spacebar:3001
    restart: unless-stopped
    ports:
      - "20080:80"
    depends_on: 
      - spacebar

volumes:
  spacebar-storage:
  db:
  nginx-site:
  letsencrypt-folder:

~/.bashrc file:

export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DATABASE=spacebar
export [email protected]

All other files in the spacebar-server-client-proxy folder are copied to the current directory without modification.

And the Caddy Compose file is as follows:

version: "3.9"

services:
  caddy:
    image: my_caddy:latest
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    environment:
      - UID=1000
      - GID=1000
    volumes:
      - /etc/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - /etc/caddy/site:/srv
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - proxy_net
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  caddy_data:
    external: true
  caddy_config:

networks:
  proxy_net:
    driver: bridge

The Caddyfile is set up like this:

{
        # TLS Options
        # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
        acme_dns cloudflare {  {  API_TOKEN  }  }

        servers :443 {
                protocol {
                        # experimental_http3
                        # strict_sni_host
                }
        }
        servers :80 {
                protocol {
                        allow_h2c
                }
        }
}

spacebar.my.domain {
        reverse_proxy host.docker.internal:20080 {
        }
}

This Caddy setup has been working correctly for other services, but when I try to access https://spacebar.my.domain/, I encounter the following error:

This page isn’t working right now
spacebar.my.domain redirected you too many times.
Try deleting your cookies.
ERR_TOO_MANY_REDIRECTS

Following a suggestion from GPT, I modified the Caddyfile to:

{
        # TLS Options
        # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
        acme_dns cloudflare { {  API_TOKEN  } }

        servers :443 {
                protocol {
                        # experimental_http3
                        # strict_sni_host
                }
        }
        servers :80 {
                protocol {
                        allow_h2c
                }
        }
}

spacebar.my.domain {
        reverse_proxy spacebar-client:80 {
        }
}

This was intended to redirect requests within the Docker network. However, I still receive the same ERR_TOO_MANY_REDIRECTS error when attempting to access the domain.

With my limited network knowledge, I have tried various searches and attempts to no avail. I am humbly reaching out to this vibrant community for help: could it be that the forwarding logic within spacebar-client itself is causing this configuration method, which has always worked for me, to no longer be effective?

If you believe this issue is unrelated to spacebar-client, I would appreciate it if you could let me know at your convenience and feel free to close this issue. If you do not have the time to address this, please feel free to leave this issue aside, as I currently have no problem accessing the service using IP:Port. Thank you for taking the time to read this.

Crahses at startup, container won't run in arm64

Hello, I'm using a RaspberryPi5 8Gb with the Raspberry Pi OS Lite image, when I try to startup the server using your docker-compose.yml template for sqlite, the container won't start and just crashes.
Here's the docker-compose.yml (I tried to change it to my settings too but no dice)

version: "3.9"
services:
  spacebar:
    image: spacebarchat/server:latest-sqlite-arm64
    ports:
      - "3001:3001"
    volumes:
      - spacebar-database:/exec/persistent/database/
      - spacebar-storage:/exec/persistent/storage
    environment:
      DATABASE: "/exec/persistent/database/database.db"
      STORAGE_PROVIDER: "file"
      STORAGE_LOCATION: "/exec/persistent/storage/"
      PORT: "3001"
volumes:
  spacebar-database:
  spacebar-storage:

Here are the logs:
_spacebar-spacebar-1_logs.txt

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.