Skip to content

Migration/docker postgres#156

Merged
TVW96 merged 26 commits intomainfrom
migration/docker-postgres
Apr 18, 2026
Merged

Migration/docker postgres#156
TVW96 merged 26 commits intomainfrom
migration/docker-postgres

Conversation

@TVW96
Copy link
Copy Markdown
Contributor

@TVW96 TVW96 commented Feb 6, 2026

Summary & Changes 📃

Summary

Integrates containerization standards, utilizing Docker CLI and Docker Desktop GUI. The added code changes have successfully reduced the overall occurrences of configuration drift, and deduplicated values across the tech-stack. By defining each component as an isolated containerized image, the entire project environment becomes standardized, including configuration mappings for service ↔ database credentials, reverse proxy ↔ service containers, and route prefixes ↔ backend API handlers.

This modular setup allows each service to be independently developed, tested, and maintained. By composing these services through Traefik’s reverse proxy, we ensure seamless routing and integration. As a result, the entire environment is production-ready, with consistent behavior across testing, development, and deployment stages.

Changes Made

  • Added: Traefik, Postgres, and PgAdmin services.
  • Added: Centralized .env file at the application root containing database variables shared across the tech stack.
  • Added: Service containers running Postgres, Next.js, NestJS, Traefik, and PgAdmin images.
  • Removed: Database compose and build process from the E2E testing workflow. The tests now use a Postgres Docker container image instead.
  • Consolidated: Frontend and backend traffic to a single port. The application now runs entirely on http://localhost (port 80).

Note

This configuration reflects the preferred production-style architecture, where services are containerized and routed through a reverse proxy.

What is the expected behavior?

With Docker Desktop open, we should be able to build the entire application with only 2 commands, accessing the website at:

  • http://localhost/ → Next.js frontend
  • http://localhost/api → NestJS backend
  • http://localhost:8080 → Traefik dashboard

How to Test 🧪

  1. In your root directory run the setup script

linux:

setup-macos-linux.sh 

windows:

setup-windows.bat
  1. Open Docker Desktop GUI & build the app container by running this command in your root directory:
npm run docker

@TVW96 TVW96 self-assigned this Feb 7, 2026
@TVW96 TVW96 marked this pull request as ready for review February 8, 2026 04:50
@beimnettes beimnettes self-requested a review February 10, 2026 23:09
Copy link
Copy Markdown
Contributor

@beimnettes beimnettes left a comment

Choose a reason for hiding this comment

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

I checked this branch locally and reviewed the changes.

The Docker setup and project structure look correct, and the application starts until required environment variables (such as JWT_SECRET) are needed. Those errors are expected locally and match the PR notes.

However, the CI checks are still failing and the branch is out of date with main. These issues should be resolved before merge.

@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
@github-actions
Copy link
Copy Markdown

✅ Full E2E Test Results

Running full test suite (critical files changed)

Status Count
✅ Passed 43
❌ Failed 0
📊 Total 43

View detailed report

@TVW96
Copy link
Copy Markdown
Contributor Author

TVW96 commented Feb 28, 2026

@NahomAlemu @beimnettes

Docker compose builds frontend, backend, and postgres. I removed these build steps from playwright and changed the playwright_api_url to match the traefik (reverse proxy) route.

I also removed the hardcoded environment configurations from playwright and github workflows, leaving a shared set of values in root to be accessed across backend, testing, and development environments. Now when app is started using Docker Compose these values are inherited.

This is similar to the previous setup but does not use the --workspace prefix(not read across containers) and requires less hardcoded values. Since values can be pulled from the shell used to compose the application.

  // Start Docker Compose services if not already running,
  // services are accessible at http://localhost (port 80) via Traefik proxy
  webServer: {
    command: "docker compose up -d && tail -f /dev/null",
    url: "http://localhost",
    reuseExistingServer: true, // Don't restart if services are already running
    timeout: 240000,
  },

Before using Docker Compose:

  1. Separate postgres databases. One for local(127.0.0.1:port/api) and another for workflows(localhost:port/api).
  2. Deduplicated project dependencies. (consistent package-lock.json updates required).
  3. Bifurcated port values. Separate url & api port locations creating CORS-policy error.
  4. Propagating environment variables. ...

The compose.yml file at root provides fallbacks for all values not found in the smoke and e2e testing when application is ran in test mode NODE_ENV: test. *Read the compose.yaml file to learn more about the project workflow. Checkout the Dockerfile to learn more on the build process.

@SeattleColleges SeattleColleges deleted a comment from github-actions bot Feb 28, 2026
Copy link
Copy Markdown
Contributor

@NahomAlemu NahomAlemu left a comment

Choose a reason for hiding this comment

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

Well done! I was able to successfully spin up the entire stack and verify the containerization strategy on my local machine.

Testing Highlights

  • Unified Routing: Confirmed Traefik correctly handles traffic at http://localhost (Frontend) and http://localhost/api (Backend/Swagger) and e2e testing.
  • Functional Flow: Successfully created a new user via Swagger and verified the login flow on the frontend - database persistence is solid.
  • Verified Hot Reload is working for both services by updating a code.

I noticed package-lock.json updated due to an npm version mismatch between my host and the container. This is fine for now, but we should standardize the npm version in the Dockerfile to avoid git noise.

docker-test

@SeattleColleges SeattleColleges deleted a comment from github-actions bot Mar 13, 2026
@github-actions
Copy link
Copy Markdown

✅ Full E2E Test Results

Running full test suite (critical files changed)

Status Count
✅ Passed 16
❌ Failed 0
📊 Total 16

View detailed report

Copy link
Copy Markdown
Contributor

@beimnettes beimnettes left a comment

Choose a reason for hiding this comment

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

I reviewed this branch locally and checked the Docker setup.

The container configuration looks correct and the services start properly using Docker Compose. The routing through http://localhost and /api works as expected with Traefik.

I also saw that the E2E tests are passing, which shows the container environment works with the testing setup.

Overall this change improves the project by making the development environment more consistent and easier to run.

@github-actions
Copy link
Copy Markdown

✅ Full E2E Test Results

Running full test suite (critical files changed)

Status Count
✅ Passed 43
❌ Failed 0
📊 Total 43

View detailed report

@TVW96 TVW96 merged commit 57754ae into main Apr 18, 2026
8 checks passed
@TVW96 TVW96 linked an issue Apr 18, 2026 that may be closed by this pull request
5 tasks
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.

Containerize Application with Docker

3 participants