Skip to content
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

Containerize Frontend & Backend #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Containerize Frontend & Backend #16

wants to merge 1 commit into from

Conversation

aashkir
Copy link
Member

@aashkir aashkir commented Jul 17, 2022

What is this PR about?

This change builds a multi-stage docker image for eelbot-ui, the output images are frontendand backend. The multi-stage build has 4 phases:

  • staging (frontend): Start with a Node.js base image, and copies relevant source files.
  • staging (backend): Start with a Python base image, Installs poetry, and copies relevant source files.
  • development (frontend): Installs the frontend project in editable mode.
  • development (backend): Installs the backend project in editable mode.
  • build (frontend): Build the frontend project into a index.html file
  • build (backend): Build the backend project into a wheel file
  • production (frontend): A clean python-alpine image that installs the build wheel file & serves it
  • production (backend): A clean nginx image that serves the index.html file & proxies requests to the backend server.

You can create development or production images by using the --target keyword during builds.

Additional changes:

  • Consolidated readme files to root directory
  • Added config file for backend, called configmodule.py resolves issue Add config support #7
  • (backend) Installed psycopg2 (hot fix, since it wasn't present in last change)
  • (frontend) Installed https-proxy-middleware and created setupProxy file so dev builds can specify which host & port to use via env variable, frontend:PORT/api/X now proxies to backend:PORT/X (for dev only)

link to my config set up

@aashkir aashkir requested review from boarnoah and right-mouse July 17, 2022 18:56
@@ -0,0 +1,125 @@
ARG REACT_APP_NAME=frontend
Copy link
Member

Choose a reason for hiding this comment

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

You'd be better of splitting this into two dockerfiles and putting them into their respective directories (frontend and backend)

@@ -0,0 +1,3 @@
.dockerignore
Copy link
Member

Choose a reason for hiding this comment

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

Is this line needed? I always assumed .dockerignore would be automatically ignored, but correct me if I'm wrong.

node_modules
build
.dockerignore
Dockerfile
Copy link
Member

Choose a reason for hiding this comment

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

Another good candidate to ignore is the .git/ folder, as well as the .gitignore file.

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