server icon indicating copy to clipboard operation
server copied to clipboard

chore: update docker scripts

Open snowyyd opened this issue 3 years ago • 6 comments

Docker scripts have been updated to fosscord staging.

Steps to deploy:

docker compose run fosscord node scripts/first_setup.js
docker compose up -d

# or if you want to use postgresql
docker compose -f docker-compose.yml -f docker-compose.postgres.yml up -d

Notes

  • You can always run the setup script outside the container, so the first command is optional.
  • Running COPY or git clone commands inside the Dockerfile is not recommended because you may want to run your own modified version of Fosscord. Please note that git clone or COPY commands may be added ONLY IF you want to publish a prebuilt image in any Docker Registry. In this case, user-made customizations can be supported through git patches.
  • canvas and bcrypt packages are fully supported.
  • Fosscord will run as non-root user. You can override this behavior by editing the Dockerfile¹ or the docker-compose.yml² file. (1, 2).
  • You can set a custom userid/groupid for the non-root user (build-time only).
  • PostgreSQL is fully supported.
  • Partial MariaDB support can be found here.

Example .env file for SQLite, PostgreSQL and MariaDB.

# SQLite example
DATABASE=database.db

# PostgreSQL example (POSTGRES_USER and POSTGRES_DB are optional)
DATABASE=postgres://user:password@postgres/dbname
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_PASSWORD=password

# MariaDB example
DATABASE=mariadb://user:password@mariadb/dbname
MARIADB_ROOT_PASSWORD=secr3tpassw0rd
MARIADB_DATABASE=fosscord
MARIADB_USER=fosscord
MARIADB_PASSWORD=password


Since Docker is fully supported, it should be added to the docs.

snowyyd avatar Sep 10 '22 03:09 snowyyd

Git is required either way as its used for identifying the commit hash

TheArcaneBrony avatar Sep 10 '22 19:09 TheArcaneBrony

Git is required either way as its used for identifying the commit hash

You are right. For this reason the Dockerfile installs the git package (although it is not used for anything else).

snowyyd avatar Sep 10 '22 23:09 snowyyd

I wonder if its possible to get the git commit without depending on git (.git/HEAD -> .git/refs/...)? Would this be overkill?

TheArcaneBrony avatar Sep 13 '22 09:09 TheArcaneBrony

I wonder if its possible to get the git commit without depending on git (.git/HEAD -> .git/refs/...)? Would this be overkill?

Well, the content of the HEAD file varies depending on the current HEAD, which can be a checked out branch or a detached head.

I think something like that is enough:

async function getCommit() {
	const head = (await fs.readFile('.git/HEAD', 'utf8')).toString().trim().replace('ref: ', '');
	return head.indexOf('/') === -1 ? head : (await fs.readFile('.git/' + head, 'utf8')).toString().trim();
}

snowyyd avatar Sep 13 '22 10:09 snowyyd

.git does not exist if you did not use git clone to download in the first place.

erkinalp avatar Sep 13 '22 11:09 erkinalp

.git does not exist if you did not use git clone to download in the first place.

On that case you don't even need the git command used in getCommitOrFail() function. If you don't git clone the repo, you can't get a referenced commit hash from it.

snowyyd avatar Sep 13 '22 11:09 snowyyd

I'm working on a new implementation that I will PR later.

Reference: https://github.com/n0bodysec/docker-images/tree/main/fosscord

snowyyd avatar Mar 13 '23 23:03 snowyyd