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

Add a helm chart and other necessary changes for Kubernetes production environment #128

Open
wants to merge 9 commits into
base: listOfMed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 73 additions & 69 deletions .github/workflows/containers-publish.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
name: "Containers: Publish"

on:
push:
tags: ["v*"]

permissions:
packages: write

jobs:
release-containers:
name: Build and Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Login to ghcr.io Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute Docker container image addresses
run: |
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
DOCKER_TAG="${GITHUB_REF:11}"

echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV

echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"

# - name: 'Pull previous Docker container image: :latest'
# run: docker pull "${DOCKER_REPOSITORY}:latest" || true

- name: "Pull previous Docker container image: frontend-static:latest"
run: docker pull "${DOCKER_REPOSITORY}/frontend-static:latest" || true

- name: "Build Docker container image: frontend-static:latest"
run: |
docker build \
--cache-from "${DOCKER_REPOSITORY}/frontend-static:latest" \
--file frontend/Dockerfile.demo \
--build-arg SERVER_NAME=localhost \
--tag "${DOCKER_REPOSITORY}/frontend-static:latest" \
--tag "${DOCKER_REPOSITORY}/frontend-static:${DOCKER_TAG}" \
frontend
- name: "Push Docker container image frontend-static:latest"
run: docker push "${DOCKER_REPOSITORY}/frontend-static:latest"

- name: "Push Docker container image frontend-static:v*"
run: docker push "${DOCKER_REPOSITORY}/frontend-static:${DOCKER_TAG}"
#
#
# - name: 'Build Docker container image: backend:latest'
# run: |
# cd backend && \
# make && \
# docker image tag "${DOCKER_REPOSITORY}/backend/local:latest" "${DOCKER_REPOSITORY}/backend:latest"
#
# - name: Push Docker container image backend:latest
# run: docker push "${DOCKER_REPOSITORY}/backend:latest"
#
# - name: Push Docker container image backend:v*
# run: docker push "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}"

# - name: Push Docker container image :v*"
# run: docker push "${DOCKER_REPOSITORY}:${DOCKER_TAG}"
name: 'Containers: Publish'

on:
push:
tags: [ 'v*' ]

permissions:
packages: write

jobs:
release-containers:
name: Build and Push
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

- name: Login to ghcr.io Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute Docker container image addresses
run: |
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
DOCKER_TAG="${GITHUB_REF:11}"

echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV

echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"

# - name: 'Pull previous Docker container image: :latest'
# run: docker pull "${DOCKER_REPOSITORY}:latest" || true
- name: 'Pull previous Docker container image: backend:latest'
run: docker pull "${DOCKER_REPOSITORY}/backend:latest" || true

- name: 'Build Docker container image: backend:latest'
run: |
cd server
docker build \
--cache-from "${DOCKER_REPOSITORY}/backend:latest" \
--file Dockerfile.prod \
--tag "${DOCKER_REPOSITORY}/backend:latest" \
--tag "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}" \
.
cd ..
- name: 'Push Docker container image backend:latest'
run: docker push "${DOCKER_REPOSITORY}/backend:latest"

- name: 'Push Docker container image backend:v*'
run: docker push "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}"

- name: 'Pull previous Docker container image: frontend:latest'
run: docker pull "${DOCKER_REPOSITORY}/frontend:latest" || true

- name: 'Build Docker container image: frontend:latest'
run: |
cd ./frontend
docker build \
--cache-from "${DOCKER_REPOSITORY}/frontend:latest" \
--file Dockerfile.prod \
--tag "${DOCKER_REPOSITORY}/frontend:latest" \
--tag "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}" \
.
cd ..
- name: 'Push Docker container image frontend:latest'
run: docker push "${DOCKER_REPOSITORY}/frontend:latest"

- name: 'Push Docker container image frontend:v*'
run: docker push "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}"
3 changes: 3 additions & 0 deletions .holo/branches/helm-chart/_balancer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[holomapping]
root = "helm-chart"
files = "**"
2 changes: 2 additions & 0 deletions .holo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[holospace]
name = "balancer"
3 changes: 0 additions & 3 deletions config/env/.env.prod.db

This file was deleted.

5 changes: 3 additions & 2 deletions config/env/env.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEBUG=True
DEBUG=TRUE
SECRET_KEY=foo
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
SQL_ENGINE=django.db.backends.postgresql
Expand All @@ -12,4 +12,5 @@ LOGIN_REDIRECT_URL=
OPENAI_API_KEY=
PINECONE_API_KEY=
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_HOST_PASSWORD=
SUPER_USER_PASSWORD=adminpassword
14 changes: 0 additions & 14 deletions config/env/env.prod

This file was deleted.

3 changes: 0 additions & 3 deletions config/env/env.prod.db

This file was deleted.

43 changes: 0 additions & 43 deletions docker-compose.prod.yml

This file was deleted.

30 changes: 0 additions & 30 deletions docker-compose.prodBackup.yml

This file was deleted.

12 changes: 9 additions & 3 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ COPY . .

RUN npm run build

FROM ghcr.io/codeforphilly/balancer-main/backend:latest as backend
# The frontend needs to get the static files from the backend for the django admin site and
# django rest framework error pages. Pulling them from the built image works but may not be the best way to do this
# because it causes the frontend image to depend on the backend image.

FROM nginx:latest

COPY nginx.conf /etc/nginx/conf.d/default.conf
# The nginx.conf file will be replaced from the helm chart.

COPY --from=builder /usr/src/app/build /usr/share/nginx/html
COPY --from=builder /usr/src/server/build /usr/share/nginx/html
COPY --from=backend /usr/src/app/static /usr/share/nginx/html/static

EXPOSE 80
EXPOSE 80
10 changes: 0 additions & 10 deletions frontend/nginx.conf

This file was deleted.

3 changes: 2 additions & 1 deletion frontend/src/components/Header/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const Chat: React.FC<ChatDropDownProps> = ({ showChat, setShowChat }) => {
};

const sendMessage = (message: ChatLogItem[]) => {
const baseUrl = import.meta.env.VITE_API_BASE_URL;
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
const url = `${baseUrl}/chatgpt/chat`;

const apiMessages = message.map((messageObject) => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/DrugSummary/DrugSummaryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ const DrugSummaryForm = () => {
};

const sendMessage = (message: ChatLogItem[]) => {
const baseUrl = import.meta.env.VITE_API_BASE_URL;
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
const url = `${baseUrl}/chatgpt/chat`;

const apiMessages = message.map((messageObject) => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/DrugSummary/DrugSummaryFormBackup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const DrugSummaryForm = () => {
}

const contentType = url ? "application/json" : "multi-part/form";
const baseUrl = import.meta.env.VITE_API_BASE_URL;
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
const completeBaseURL = `${baseUrl}/chatgpt`;
try {
// TODO change this to actual endpoint url once hosted
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/pages/Feedback/FeedbackForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const FeedbackForm = () => {

try {
const res = await axios.post(
// this URL won't work
"http://localhost:3001/text_extraction",
formData,
{
Expand All @@ -86,14 +87,16 @@ const FeedbackForm = () => {
},
onSubmit: async (values) => {
setFeedback("");
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
try {
// Call 1: Create Feedback request
const response = await axios.post(
"http://localhost:8000/api/jira/create_new_feedback/",
const response = await axios.post(baseUrl + "/jira/create_new_feedback/",
{
name: values.name,
email: values.email,
message: values.message,
// the backend endpoint also expects a feedbackType
},
{
headers: {
Expand All @@ -113,7 +116,7 @@ const FeedbackForm = () => {
formData.append("attachment", values.image);

const response2 = await axios.post(
"http://localhost:8000/api/jira/upload_servicedesk_attachment/",
baseUrl + "/jira/upload_servicedesk_attachment/",
formData,
{
headers: {
Expand All @@ -128,7 +131,7 @@ const FeedbackForm = () => {

// Step 3: Attach upload image to feedback request
const response3 = await axios.post(
"http://localhost:8000/api/jira/attach_feedback_attachment/",
baseUrl + "/jira/attach_feedback_attachment/",
{
issueKey: issueKey,
tempAttachmentId: attachmentId,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/PatientManager/NewPatientForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ const NewPatientForm = ({
setIsLoading(true); // Start loading

try {
const baseUrl = import.meta.env.VITE_API_BASE_URL;
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
const url = `${baseUrl}/chatgpt`;
console.log(payload);

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/PatientManager/PatientSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const PatientSummary = ({
setClickedMedication(medication);
setLoading(true);
try {
const baseUrl = import.meta.env.VITE_API_BASE_URL;
let baseUrl = window.location.origin + '/api';
baseUrl = baseUrl.replace(":3000", ":8000");
const postBody = {
diagnosis: medication,
};
Expand Down
Loading