-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating dockerfile to include api server (#14)
The existing dockerfile only ran the frontend React app. It needed to have the Python API included. - Switched from alpine to ubuntu because alpine was giving me grief about installing python requirements, but this required following the node people's cumbersome instructions for how to get an even remotely up-to-date version of node because ubuntu defaults to v12 😱 - Created a shell script per docker recommendations to start the frontend and backend servers (took some time to track down that I now need to provide the aught host param to vite to expose the web interface outside the container)
- Loading branch information
Showing
2 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,33 +1,41 @@ | ||
# syntax=docker/dockerfile:1 | ||
# This docker container runs the web portal | ||
# Slim Linux image | ||
FROM alpine:latest | ||
FROM ubuntu:latest | ||
LABEL description="Ramanujan Machine Web Portal" | ||
|
||
# set working directory | ||
WORKDIR /srv/ramanujan-machine-portal | ||
|
||
# install node | ||
RUN apk update && apk add nodejs npm | ||
RUN apt-get update && apt-get -y install python3 python3-pip ca-certificates curl gnupg | ||
|
||
COPY ./react-frontend/package.json ./ | ||
COPY ./react-frontend/package-lock.json ./ | ||
COPY ./react-frontend/tsconfig.json ./ | ||
RUN mkdir -p /etc/apt/keyrings | ||
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg | ||
ENV NODE_MAJOR=20 | ||
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list | ||
|
||
# install node package dependencies | ||
RUN npm ci | ||
RUN apt-get update && apt-get -y install nodejs | ||
|
||
COPY ./react-frontend ./ | ||
|
||
# Copy project files | ||
COPY ./react-frontend/src ./src | ||
COPY ./react-frontend/public ./public | ||
# install node package dependencies | ||
RUN npm install | ||
|
||
# Build project | ||
# Build frontend project | ||
RUN npm run build | ||
|
||
# remove dev dependencies | ||
RUN npm prune --production | ||
# RUN npm install -g serve | ||
# copy API files | ||
COPY ./python-backend/Pipfile* ./ | ||
COPY ./python-backend/*.py ./ | ||
COPY ./python-backend/requirements.txt ./ | ||
|
||
# install Python dependencies | ||
RUN pip3 install -r requirements.txt | ||
RUN pip3 install uvicorn | ||
|
||
EXPOSE 5173 | ||
EXPOSE 8000 | ||
|
||
EXPOSE 3000 | ||
#ENTRYPOINT ["serve", "-s", "build"] | ||
ENTRYPOINT ["npm", "run", "start"] | ||
COPY docker_start.sh docker_start.sh | ||
RUN chmod +x docker_start.sh | ||
CMD ./docker_start.sh |
This file contains 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,13 @@ | ||
#!/bin/bash | ||
|
||
# Start the first process | ||
npx vite --host "0.0.0.0" --port 5173 & | ||
|
||
# Start the second process | ||
uvicorn main:app --host "0.0.0.0" --port 8000 & | ||
|
||
# Wait for any process to exit | ||
wait -n | ||
|
||
# Exit with status of process that exited first | ||
exit $? |