Skip to content

feat: add docker deploy #247

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

Merged
merged 9 commits into from
Jul 17, 2025
Merged

feat: add docker deploy #247

merged 9 commits into from
Jul 17, 2025

Conversation

lu-yg
Copy link
Collaborator

@lu-yg lu-yg commented Jul 16, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced Docker Compose setup for multi-service deployment, including backend, frontend, and MySQL database services.
    • Added comprehensive MySQL database schema to support a multi-tenant design and application platform with versioning and internationalization.
    • Added Nginx configuration for serving static files and proxying API requests.
    • Added Maven and Docker build configurations for streamlined application packaging and deployment.
  • Configuration

    • Updated application settings for file upload limits, database connections, logging, and CORS.
    • Added MySQL and server configuration files to support UTF-8 encoding and optimized database settings.
    • Included Maven repository mirror and deployment server credentials.
  • Bug Fixes

    • Updated SQL schema indexes and column definitions to improve data integrity and support nullable tenant IDs.

Copy link

coderabbitai bot commented Jul 16, 2025

Walkthrough

Several configuration and infrastructure files were introduced or updated to support a multi-service application platform. These changes include new Docker and Maven configuration files, MySQL database schema and migration scripts, Nginx server configuration, and Spring Boot environment-specific YAML files. No code or API signatures were altered.

Changes

File(s) Change Summary
docker-compose.yml, Dockerfile Added Docker Compose and Dockerfile for multi-service setup and build/runtime configuration.
docker-deploy-data/mysql/conf/my.cnf Added MySQL configuration for UTF-8 multibyte character set and Unicode collation.
docker-deploy-data/mysql/init/create_all_tables_ddl_v1.0.0.mysql.sql Introduced comprehensive MySQL DDL for initial schema creation with multi-tenant, versioning, and i18n support.
docker-deploy-data/mysql/init/update_all_tables_ddl.sql, docker-deploy-data/mysql/init/update_tables_ddl_v1.0.0_2025_0527.sql Added SQL migration scripts to alter indexes and allow nullable tenant IDs in multiple tables.
docker-deploy-data/nginx.conf Added Nginx configuration for static file serving and proxying backend requests.
settings.xml Added Maven settings with server credentials and Aliyun mirror configuration.
app/src/main/resources/application-alpha.yml, app/src/main/resources/application-dev.yml Added/updated Spring Boot YAML configs for environment-specific settings, file upload limits, and DB connection.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Nginx
    participant Backend (tiny-engine-back)
    participant MySQL

    User->>Nginx: HTTP request (e.g., /index.html)
    Nginx-->>User: Serve static file (if exists)
    User->>Nginx: API request (e.g., /xxx-center/...)
    Nginx->>Backend (tiny-engine-back): Proxy API request
    Backend (tiny-engine-back)->>MySQL: Query/update data
    MySQL-->>Backend (tiny-engine-back): DB response
    Backend (tiny-engine-back)-->>Nginx: API response
    Nginx-->>User: Return API response
Loading

Poem

🐇
Docker hums and MySQL sings,
Nginx serves and Spring Boot springs.
Tables bloom in schema light,
Configs set for day and night.
With every build, the platform grows—
A rabbit’s dream, as code bestows!
🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9ad907 and 899816f.

📒 Files selected for processing (1)
  • docker-deploy-data/nginx.conf (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker-deploy-data/nginx.conf
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (8)
docker-deploy-data/mysql/init/update_all_tables_ddl.sql (1)

7-29: Mass tenant_id NOT NULL → NULL change – audit application code & constraints
Allowing NULL tenant IDs across ~20 tables dramatically changes data-isolation guarantees. Ensure:

  1. Hibernate / MyBatis mappings don’t still have @NotNull.
  2. Foreign-key relations or unique indexes that previously included tenant_id still behave correctly with nullable columns.
  3. Application logic that filters by tenant_id doesn’t assume non-null.

Consider adding NOT-NULL + default tenant for records that truly have no tenant context instead of blanket NULL.

dockerfile (1)

3-3: Use COPY instead of ADD
ADD has side-effects (automatic tar extraction & remote URL fetch) that are not needed for a simple context copy. Stick to COPY for predictability and to satisfy Hadolint DL3020.

-ADD . .
+COPY . .
docker-deploy-data/nginx.conf (1)

14-14: server_name 0.0.0.0 is invalid
Use _ (catch-all) or an actual host/domain. 0.0.0.0 can break TLS SNI and log parsing.

-    server_name  0.0.0.0;
+    server_name  _;
app/src/main/resources/application-alpha (1)

57-65: Log file path may be unwritable in container
/logs normally requires root or a mounted volume. Ensure the directory exists with correct permissions or point logging to STDOUT for Docker.

docker-compose.yml (3)

13-16: Prefer named volumes over bind mounts for MySQL
Host-path binds tie data to the project directory and can cause UID/permission drift. Example:

volumes:
  db-data:
services:
  tiny-engine-data:
    volumes:
      - db-data:/var/lib/mysql

21-24: Use canonical Dockerfile name
Some build tools assume Dockerfile; renaming to lowercase may confuse them. If renaming is required, document it in README.


25-27: depends_on lacks health-checks
Startup order isn’t guaranteed; add healthcheck or wait-for-it script so the backend waits for MySQL readiness.

docker-deploy-data/mysql/init/create_all_tables_ddl_v1.0.0.mysql.sql (1)

33-35: No foreign keys defined
Tables reference each other through *_id fields yet no FK constraints exist. This sacrifices referential integrity and cascades. Consider adding foreign keys or document why they’re intentionally omitted.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abcd445 and 7253d72.

📒 Files selected for processing (10)
  • app/src/main/resources/application-alpha (1 hunks)
  • app/src/main/resources/application-dev.yml (1 hunks)
  • docker-compose.yml (1 hunks)
  • docker-deploy-data/mysql/conf/my.cnf (1 hunks)
  • docker-deploy-data/mysql/init/create_all_tables_ddl_v1.0.0.mysql.sql (1 hunks)
  • docker-deploy-data/mysql/init/update_all_tables_ddl.sql (1 hunks)
  • docker-deploy-data/mysql/init/update_tables_ddl_v1.0.0_2025_0527.sql (1 hunks)
  • docker-deploy-data/nginx.conf (1 hunks)
  • dockerfile (1 hunks)
  • settings.xml (1 hunks)
🧰 Additional context used
🪛 Checkov (3.2.334)
dockerfile

[HIGH] 4-4: Ensure that certificate validation isn't disabled with wget

(CKV2_DOCKER_3)

🪛 Hadolint (2.12.0)
dockerfile

[error] 3-3: Use COPY instead of ADD for files and folders

(DL3020)

🪛 YAMLlint (1.37.1)
docker-compose.yml

[error] 17-17: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 36-36: trailing spaces

(trailing-spaces)


[error] 38-38: trailing spaces

(trailing-spaces)

🔇 Additional comments (7)
settings.xml (1)

24-37: Mirror configuration looks good – Aliyun mirror is correctly scoped to *.

app/src/main/resources/application-dev.yml (1)

5-8: Multipart limits added – LGTM
10MB is accepted by Spring Boot; property names are correct. Double-check that any reverse proxy (e.g., Nginx) and Tomcat maxSwallowSize limits are ≥ 10 MB to avoid 413 errors.

docker-deploy-data/mysql/init/update_tables_ddl_v1.0.0_2025_0527.sql (1)

1-2: Unique → non-unique index change may allow duplicate rows
Dropping u_idx_block_group (unique) and recreating it as a plain INDEX removes the uniqueness constraint on (tenant_id,platform_id,name,app_id). If this was accidental, duplicates could creep in and break business logic.

Confirm intent; otherwise use ADD UNIQUE INDEX.

docker-deploy-data/mysql/init/update_all_tables_ddl.sql (1)

1-6: Uniqueness dropped on t_component / t_datasource
Same pattern: unique indexes are recreated without the UNIQUE keyword. Verify that the application truly no longer relies on uniqueness; else switch to ADD UNIQUE INDEX.

dockerfile (1)

15-16: Jar copy path likely wrong
/app/app/target/… adds an extra app directory (WORKDIR is already /app). Unless the build creates /app/app/target, this will fail at runtime.

-COPY --from=build /app/app/target/tiny-engine-app-*.jar /app/tiny-engine-app.jar
+COPY --from=build /app/target/tiny-engine-app-*.jar /app/tiny-engine-app.jar

Apply the same check for the base module path.

Likely an incorrect or invalid review comment.

docker-deploy-data/nginx.conf (1)

27-28: Inconsistent root for error pages
root html; conflicts with the earlier /usr/share/nginx/html. Use alias or reuse the same root.

app/src/main/resources/application-alpha (1)

28-30: Profile activation seems wrong
File is named application-alpha yet on-profile: dev is set. This profile will never load unless dev is active. Confirm intent.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
Dockerfile (2)

3-3: Prefer COPY over ADD for predictable behaviour

ADD . . brings in tar-auto-extraction semantics you don’t need and triggers Hadolint DL3020. A straight file/folder copy is clearer.

-ADD . .
+COPY . .

18-19: Run as non-root for better container hardening

The final image keeps the default root user. Consider creating an unprivileged user and dropping to it:

RUN useradd -r -u 1001 appuser
USER appuser

Also move EXPOSE 9090 above ENTRYPOINT for readability (no functional impact).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7253d72 and 8adea2a.

📒 Files selected for processing (1)
  • Dockerfile (1 hunks)
🧰 Additional context used
🪛 Checkov (3.2.334)
Dockerfile

[HIGH] 4-4: Ensure that certificate validation isn't disabled with wget

(CKV2_DOCKER_3)

🪛 Hadolint (2.12.0)
Dockerfile

[error] 3-3: Use COPY instead of ADD for files and folders

(DL3020)

🔇 Additional comments (1)
Dockerfile (1)

15-16: Wildcard copy may pick up multiple JARs – verify the result

tiny-engine-app-*.jar (and base) could match SNAPSHOT + test jars, leading to ambiguous or multiple copies. Ensure the package phase produces exactly one artefact, or copy via the full file name emitted by Maven (mvn -q -Dexpression=project.build.finalName …).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
Dockerfile (2)

4-8: Manual Maven download with --no-check-certificate is still insecure
Previous review already highlighted that disabling TLS validation (CKV2_DOCKER_3) opens the door to MITM attacks. Either:

  1. Replace the whole build stage with the official maven:3.9.8-eclipse-temurin-17 image, or
  2. Keep the manual download but drop --no-check-certificate and add checksum verification.

This comment reiterates the unresolved critical security issue.


1-12: Re-use the official Maven image to collapse layers and improve cache hits

Manually installing Maven duplicates what maven:3.9.8-eclipse-temurin-17 already provides, wastes ~100 MB, and complicates the Dockerfile. See earlier suggestion for the concise multi-stage pattern.

docker-compose.yml (1)

9-10: Hard-coded MySQL root password persists

Storing credentials in-repo is insecure and violates secret-management best practices. Move MYSQL_ROOT_PASSWORD to an env_file, Docker secret, or CI-injected variable.

🧹 Nitpick comments (3)
Dockerfile (1)

3-3: Prefer COPY over ADD for context files

ADD . . triggers additional, rarely-needed behaviors (tar/remote URL handling) and is flagged by Hadolint DL3020. Switch to COPY for clarity and to avoid accidental surprises.

-ADD . .
+COPY . .
docker-compose.yml (2)

13-16: Use named volumes instead of repo-relative host paths

Mounting ./docker-deploy-data/mysql/... ties deployments to the repo layout and can cause permission clashes on different hosts. Define named volumes to improve portability and persist data across rebuilds:

volumes:
  mysql-data:
  mysql-conf:
  mysql-init:
  mysql-logs:

services:
  tiny-engine-data:
    ...
    volumes:
      - mysql-data:/var/lib/mysql
      - mysql-conf:/etc/mysql/conf.d
      - mysql-init:/docker-entrypoint-initdb.d
      - mysql-logs:/logs

17-38: Trailing whitespace—cosmetic but noisy in diffs

Lines 17, 25, 36 and 38 carry trailing spaces flagged by YAMLlint. Strip them to keep future diffs clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8adea2a and a9ad907.

📒 Files selected for processing (3)
  • Dockerfile (1 hunks)
  • app/src/main/resources/application-alpha.yml (1 hunks)
  • docker-compose.yml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/src/main/resources/application-alpha.yml
🧰 Additional context used
🪛 Checkov (3.2.334)
Dockerfile

[HIGH] 4-4: Ensure that certificate validation isn't disabled with wget

(CKV2_DOCKER_3)

🪛 Hadolint (2.12.0)
Dockerfile

[error] 3-3: Use COPY instead of ADD for files and folders

(DL3020)

🪛 YAMLlint (1.37.1)
docker-compose.yml

[error] 17-17: trailing spaces

(trailing-spaces)


[error] 25-25: trailing spaces

(trailing-spaces)


[error] 36-36: trailing spaces

(trailing-spaces)


[error] 38-38: trailing spaces

(trailing-spaces)

@hexqi hexqi merged commit 553f6af into opentiny:develop Jul 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants