server
server copied to clipboard
chore: update docker scripts
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
COPYorgit clonecommands inside theDockerfileis not recommended because you may want to run your own modified version of Fosscord. Please note thatgit cloneorCOPYcommands 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. canvasandbcryptpackages are fully supported.- Fosscord will run as non-root user. You can override this behavior by editing the
Dockerfile¹ or thedocker-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.
Git is required either way as its used for identifying the commit hash
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).
I wonder if its possible to get the git commit without depending on git (.git/HEAD -> .git/refs/...)? Would this be overkill?
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();
}
.git does not exist if you did not use git clone to download in the first place.
.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.
I'm working on a new implementation that I will PR later.
Reference: https://github.com/n0bodysec/docker-images/tree/main/fosscord