-
Notifications
You must be signed in to change notification settings - Fork 20
Issue #000 feat: User service docker compose file with postgres #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||
| SERVER_PORT=3000 | ||||||||||||||
| PORT=3010 | ||||||||||||||
| IMAGEPATH=./uploads | ||||||||||||||
| ADAPTERSOURCE=postgres | ||||||||||||||
| KEYCLOAK=https://keycloak-tekdi.org/auth/ | ||||||||||||||
| KEYCLOAK_ADMIN=admin/realms/master/users | ||||||||||||||
| KEYCLOAK_ADMIN=admin/realms/tekdi/users #creation in realm | ||||||||||||||
| KEYCLOAK_USER_TOKEN=realms/tekdi/protocol/openid-connect/token | ||||||||||||||
| KEYCLOAK_CLIENT_ID=Tekdi | ||||||||||||||
| KEYCLOAK_REALM=Tekdi | ||||||||||||||
| KEYCLOAK_CLIENT_SECRET=************* | ||||||||||||||
| KEYCLOAK_USERNAME=admin | ||||||||||||||
| KEYCLOAK_PASSWORD='**************' | ||||||||||||||
| KEYCLOAK_ADMIN_TOKEN=realms/master/protocol/openid-connect/token | ||||||||||||||
| RBAC_JWT_EXPIRES_IN=864000 | ||||||||||||||
| RBAC_JWT_SECRET=3609eeeab5d80e87****692139123****87872****** | ||||||||||||||
| KEYCLOAK_REALM_RSA_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\/l3ctlyzVq+8uiQMCW/**********++/+GHuPy+/\n-----END PUBLIC KEY-----" | ||||||||||||||
|
Comment on lines
+11
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Hard-coding secrets in VCS → high risk of credential leakage Client secrets, JWT keys and database passwords are committed in plain text. Even in private repos this is dangerous and complicates rotation. Move secrets to Docker/Swarm/K8s “secrets”, or at least mount an external, un-tracked env file: # docker-compose.yml
secrets:
keycloak_client_secret:
file: ./secrets/keycloak_client_secret
...
env_file:
- .env.docker # non-sensitive values
secrets:
- keycloak_client_secretAlso applies to: 24-24 🧰 Tools🪛 dotenv-linter (3.3.0)[warning] 11-11: [UnorderedKey] The KEYCLOAK_CLIENT_SECRET key should go before the KEYCLOAK_REALM key [warning] 12-12: [UnorderedKey] The KEYCLOAK_USERNAME key should go before the KEYCLOAK_USER_TOKEN key [warning] 13-13: [QuoteCharacter] The value has quote characters (', ") [warning] 13-13: [UnorderedKey] The KEYCLOAK_PASSWORD key should go before the KEYCLOAK_REALM key [warning] 14-14: [UnorderedKey] The KEYCLOAK_ADMIN_TOKEN key should go before the KEYCLOAK_CLIENT_ID key [warning] 15-15: [UnorderedKey] The RBAC_JWT_EXPIRES_IN key should go before the SERVER_PORT key [warning] 16-16: [UnorderedKey] The RBAC_JWT_SECRET key should go before the SERVER_PORT key [warning] 17-17: [TrailingWhitespace] Trailing whitespace detected [warning] 17-17: [UnorderedKey] The KEYCLOAK_REALM_RSA_PUBLIC_KEY key should go before the KEYCLOAK_USERNAME key 🤖 Prompt for AI Agents |
||||||||||||||
| NOTIFICATION_URL=http://localhost:4001 | ||||||||||||||
| PASSWORD_RESET_JWT_EXPIRES_IN=3600000 | ||||||||||||||
| POSTGRES_HOST=postgres #Do not change this as postgres runs in a container with this name | ||||||||||||||
| POSTGRES_PORT=5431 | ||||||||||||||
| POSTGRES_DATABASE=postgresdb | ||||||||||||||
|
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusive
The compose service exposes the database on the default container port 5432, but this env file hard-codes 5431. Unless the application explicitly remaps, the connection will be refused. -POSTGRES_PORT=5431
+POSTGRES_PORT=5432Verify the app’s datasource configuration after changing the port. Update When services communicate over Docker’s internal network, they use the container port (5432), not the host-published port. Please adjust the environment file accordingly: • File: -POSTGRES_PORT=5431
+POSTGRES_PORT=5432After updating, verify your application’s datasource configuration connects successfully to the 📝 Committable suggestion
Suggested change
🧰 Tools🪛 dotenv-linter (3.3.0)[warning] 20-20: [UnorderedKey] The POSTGRES_HOST key should go before the RBAC_JWT_EXPIRES_IN key [warning] 20-20: [ValueWithoutQuotes] This value needs to be surrounded in quotes [warning] 21-21: [UnorderedKey] The POSTGRES_PORT key should go before the RBAC_JWT_EXPIRES_IN key [warning] 22-22: [UnorderedKey] The POSTGRES_DATABASE key should go before the POSTGRES_HOST key 🤖 Prompt for AI Agents |
||||||||||||||
| POSTGRES_USERNAME=tekdi | ||||||||||||||
| POSTGRES_PASSWORD="*******" | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| # Stage 1: Install dependencies | ||
| FROM node:20 as dependencies | ||
| WORKDIR usr/src/app | ||
| COPY package*.json ./ | ||
| WORKDIR /usr/src/app | ||
| COPY package*.json ./ | ||
| RUN npm install | ||
|
|
||
| # Stage 2: Build and run | ||
| FROM node:20 as runner | ||
| WORKDIR /usr/src/app | ||
| COPY --from=dependencies /usr/src/app/node_modules ./node_modules | ||
| COPY . . | ||
| RUN npm run build | ||
|
|
||
| EXPOSE 3000 | ||
| CMD ["npm", "start"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,27 @@ | ||
| version: "3.6" | ||
| version: '3.6' | ||
|
|
||
| services: | ||
| backend: | ||
| image: shiksha-backend-2.0 | ||
| container_name: "shiksha-backend-2.0" | ||
| restart: always | ||
| user-service: | ||
| image: vaishali007/user-microservice:latest | ||
| ports: | ||
| - 3000:3000 | ||
| - "3000:3000" | ||
| env_file: | ||
| - /home/ubuntu-backend-shiksha2.0/.env | ||
| - .env.docker | ||
| depends_on: | ||
| - postgres | ||
|
|
||
| postgres: | ||
| image: postgres:14 | ||
| container_name: postgres | ||
| restart: always | ||
| ports: | ||
| - "15432:5432" | ||
| environment: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: oblf | ||
| volumes: | ||
| - pgdata:/var/lib/postgresql/data | ||
|
|
||
| volumes: | ||
| pgdata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate
KEYCLOAK_ADMINsilently overwrites the first valueLine 7 defines the same key a second time, so the first assignment on line 6 is discarded at runtime. This is extremely easy to miss and can break user-management calls that still expect the master-realm URL.
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (3.3.0)
[warning] 6-6: [UnorderedKey] The KEYCLOAK_ADMIN key should go before the PORT key
[warning] 7-7: [DuplicatedKey] The KEYCLOAK_ADMIN key is duplicated
[warning] 7-7: [UnorderedKey] The KEYCLOAK_ADMIN key should go before the KEYCLOAK_ADMIN key
[warning] 7-7: [ValueWithoutQuotes] This value needs to be surrounded in quotes
[warning] 8-8: [UnorderedKey] The KEYCLOAK_USER_TOKEN key should go before the PORT key
🤖 Prompt for AI Agents