From 4bd8af02faea80fc23b185f43e206bccbd39feb4 Mon Sep 17 00:00:00 2001 From: pan261 Date: Sat, 12 Feb 2022 15:33:00 -0500 Subject: [PATCH] docker postgres permission issues --- README.md | 9 +++++++++ docker-compose.yml | 5 ++++- postgres/init/create_tables.sql | 2 +- postgres/wsl.conf | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 postgres/wsl.conf diff --git a/README.md b/README.md index 61ff014..369693c 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,12 @@ NGROK_AUTH=[ngrok_auth_token] - You will also need an ngrok account (free tier works): https://ngrok.com/ - The webhook token can by anything, here is an example: https://forge.autodesk.com/en/docs/webhooks/v1/reference/http/tokens-POST/ + +## Database +- You will need to install postgres to connect to the server through terminal: `psql -h localhost -p 5432 -d filesync -U user` + - User, password, and db are all configured in the environment file +- To reset the db, delete the /postgres/db_data folder + +### File Permission Issues with Docker +- If on WSL, you may need to copy /postgres/wsl.conf into /etc/wsl.conf and restart WSL +- On Linux, you can run `sudo chown -R $USER postgres/db_data/` for any permissions issues after initializing the db \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 42b5ff5..ef34b79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: "3.8" services: ngrok: + container_name: ngrok image: wernight/ngrok:latest ports: - 4040:4040 @@ -13,15 +14,17 @@ services: # access through `psql -h localhost -p 5432 -d filesync -U user`, password is 'pass' # to be able to build after the initializing the db, you may need to run `sudo chown -R $USER db_data/` database: + container_name: postgres image: 'postgres:13' env_file: ./.env volumes: - - ./postgres/db_data/:/var/lib/postgresql/data/ + - ./postgres/db_data/:/var/lib/postgresql/data:z - ./postgres/init/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql ports: - ${PORT_DB}:${PORT_DB} server: + container_name: server build: context: . dockerfile: Dockerfile diff --git a/postgres/init/create_tables.sql b/postgres/init/create_tables.sql index 6ff2e53..366fc39 100644 --- a/postgres/init/create_tables.sql +++ b/postgres/init/create_tables.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS storage ( folder_name VARCHAR(8) NOT NULL, file_version INT NOT NULL, fusion_id VARCHAR(50), - PRIMARY KEY (file_name_ext, folder_name) + PRIMARY KEY (file_display_name, folder_name) ); CREATE TABLE IF NOT EXISTS archive ( diff --git a/postgres/wsl.conf b/postgres/wsl.conf new file mode 100644 index 0000000..07cca74 --- /dev/null +++ b/postgres/wsl.conf @@ -0,0 +1,16 @@ +[automount] +enabled = true +options = "metadata,uid=1000,gid=1000,umask=0022,fmask=11,case=off" +mountFsTab = false +crossDistro = true + +[filesystem] +umask = 0022 + +[network] +generateHosts = true +generateResolvConf = true + +[interop] +enabled = true +appendWindowsPath = true \ No newline at end of file