-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: support external Redis configuration #4443
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
Open
satoukouga
wants to merge
23
commits into
Dokploy:canary
Choose a base branch
from
satoukouga:feat/add-external-redis-feature
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9f10f0f
fix(migrate-auth-secret): exit cleanly when there are no 2FA records
ngenohkevin a714e0f
Merge pull request #4394 from ngenohkevin/fix/migrate-auth-secret-exi…
Siumauricio 754774e
feat(compose): add import from base64 in create service dropdown
Siumauricio 63e33a2
[autofix.ci] apply automated fixes
autofix-ci[bot] 7a568aa
Merge pull request #4395 from Dokploy/feat/import-compose-from-base64
Siumauricio f8fcf68
Enhance version synchronization workflow to include SDK repository
Siumauricio 558d809
feat(deployment): add readLogs procedure to fetch deployment logs
Siumauricio aff200f
feat(deployment): add server access validation for deployment actions
Siumauricio 67278d8
feat(organization): prevent inviting users with owner role
Siumauricio 1fdbe87
feat(user): implement session cleanup on user update
Siumauricio a50f958
feat(settings): add copy button to server IP in web server settings (…
Siumauricio 8d88a34
fix: copy Dokploy server IP when clicking server badge (#4390)
vadamk ef0cf9b
fix: responsive layout (#4391)
nhridoy 6e342ee
fix: automatically converting username to lowercase both in creation …
Baker 4da75ea
feat: support external Redis configuration
satoukouga a6e8530
feat: add external Redis configuration and refactor related imports
satoukouga 74dcfd9
feat: refactor Redis imports
satoukouga 9b91b6c
feat: update Redis command and args structure for consistency across …
satoukouga 7d958fd
feat: refactor Redis connection and initialization for external confi…
satoukouga fade860
feat: update redis-constants for improved configuration handling
satoukouga d85bc9c
feat: add support for external Redis configuration in initialization
satoukouga 8afc45c
feat: improve Redis configuration handling and enhance error checking…
satoukouga d096823
feat: streamline Redis configuration and enhance error handling in setup
satoukouga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import fs from "node:fs"; | ||
|
|
||
| // Mock fs for readSecret tests | ||
| vi.mock("node:fs"); | ||
|
|
||
| // Mock dockerode to verify service settings | ||
| const mockCreateService = vi.fn().mockResolvedValue({}); | ||
| const mockGetService = vi.fn().mockReturnValue({ | ||
| inspect: vi.fn().mockRejectedValue(new Error("Not found")), | ||
| update: vi.fn().mockResolvedValue({}), | ||
| }); | ||
|
|
||
| vi.mock("dockerode", () => { | ||
| return { | ||
| default: vi.fn().mockImplementation(function() { | ||
| return { | ||
| createService: mockCreateService, | ||
| getService: mockGetService, | ||
| pull: vi.fn().mockResolvedValue({}), | ||
| }; | ||
| }), | ||
| }; | ||
| }); | ||
|
|
||
| describe("redis-connection", () => { | ||
| afterEach(() => { | ||
| vi.resetModules(); | ||
| vi.unstubAllEnvs(); | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| it("should use REDIS_URL if provided", async () => { | ||
| vi.stubEnv("REDIS_URL", "redis://user:pass@remote-host:6379/1"); | ||
|
|
||
| const { redisConfig } = await import("../../server/queues/redis-connection"); | ||
|
|
||
| expect(redisConfig).toEqual({ | ||
| url: "redis://user:pass@remote-host:6379/1", | ||
| }); | ||
| }, 30000); | ||
|
|
||
| it("should use individual env vars if REDIS_URL is not provided", async () => { | ||
| vi.stubEnv("REDIS_HOST", "custom-host"); | ||
| vi.stubEnv("REDIS_PORT", "1234"); | ||
| vi.stubEnv("REDIS_DB_INDEX", "2"); | ||
| vi.stubEnv("REDIS_PASSWORD", "secret"); | ||
| vi.stubEnv("REDIS_USERNAME", "admin"); | ||
|
|
||
| const { redisConfig } = await import("../../server/queues/redis-connection"); | ||
|
|
||
| expect(redisConfig).toEqual({ | ||
| host: "custom-host", | ||
| port: 1234, | ||
| db: 2, | ||
| password: "secret", | ||
| username: "admin", | ||
| }); | ||
| }); | ||
|
|
||
| it("should read password from REDIS_PASSWORD_FILE if provided", async () => { | ||
| vi.stubEnv("REDIS_PASSWORD_FILE", "/tmp/password.txt"); | ||
| vi.mocked(fs.readFileSync).mockReturnValue("file-secret\n"); | ||
|
|
||
| const { redisConfig } = await import("../../server/queues/redis-connection"); | ||
|
|
||
| expect(redisConfig.password).toBe("file-secret"); | ||
| expect(fs.readFileSync).toHaveBeenCalledWith("/tmp/password.txt", "utf8"); | ||
| }); | ||
|
|
||
| it("should fallback to defaults in development", async () => { | ||
| vi.stubEnv("NODE_ENV", "development"); | ||
|
|
||
| const { redisConfig } = await import("../../server/queues/redis-connection"); | ||
|
|
||
| expect(redisConfig).toEqual({ | ||
| host: "127.0.0.1", | ||
| port: 6379, | ||
| db: 0, | ||
| }); | ||
| }); | ||
|
|
||
| it("should fallback to production defaults", async () => { | ||
| vi.stubEnv("NODE_ENV", "production"); | ||
|
|
||
| const { redisConfig } = await import("../../server/queues/redis-connection"); | ||
|
|
||
| expect(redisConfig).toEqual({ | ||
| host: "dokploy-redis", | ||
| port: 6379, | ||
| db: 0, | ||
| }); | ||
| }); | ||
|
|
||
| it("should verify initializeRedis creates service with correct Command and Args when password is set", async () => { | ||
| vi.stubEnv("REDIS_PASSWORD", "test-pass"); | ||
| vi.stubEnv("NODE_ENV", "production"); | ||
|
|
||
| // We need to import initializeRedis AFTER stubbing the env | ||
| const { initializeRedis } = await import("@dokploy/server/setup/redis-setup"); | ||
|
|
||
| await initializeRedis(); | ||
|
|
||
| expect(mockCreateService).toHaveBeenCalledWith(expect.objectContaining({ | ||
| TaskTemplate: expect.objectContaining({ | ||
| ContainerSpec: expect.objectContaining({ | ||
| Command: ["redis-server"], | ||
| Args: ["--requirepass", "test-pass"], | ||
| }) | ||
| }) | ||
| })); | ||
| }, 30000); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.