Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lucca93 committed Oct 29, 2023
1 parent b002d2a commit 140ea96
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Expand Up @@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9"
python = ">=3.9,<4.0"
pandas = "*"
scikit-learn = "^1.3.2"
supabase = "^1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Expand Up @@ -11,7 +11,7 @@ COPY backend/pyproject.toml backend/poetry.lock /app/

# Install dependencies without creating a virtual environment
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi
&& poetry install --only main --no-interaction --no-ansi

# Install Gunicorn
RUN pip install gunicorn
Expand Down
59 changes: 59 additions & 0 deletions docker/Dockerfile_GitConnect
@@ -0,0 +1,59 @@
# --- Backend Build Stage ---
FROM python:3.9-slim as backend

WORKDIR /app

# Install git and Poetry
RUN apt-get update && apt-get install -y git \
&& pip install poetry

# Clone the repository from GitHub
RUN git clone https://github.com/your-username/your-repo.git .

# Change to the backend directory
WORKDIR /app/backend

# Install dependencies without creating a virtual environment
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi

# --- Frontend Build Stage ---
FROM node:14 as frontend

WORKDIR /app

# Install git
RUN apt-get update && apt-get install -y git

# Clone the repository from GitHub
RUN git clone https://github.com/TobiasSchaeuble-EH/LunchHeroes.git .

# Change to the frontend directory
WORKDIR /app/frontend

# Install dependencies
RUN npm install

# Build the frontend
RUN npm run build

# --- Nginx Stage ---
FROM nginx:alpine

# Copy the built frontend files to the Nginx server
COPY --from=frontend /app/frontend/build /usr/share/nginx/html

# Copy the backend app to a directory served by Gunicorn
COPY --from=backend /app/backend /app

# Set up Gunicorn to serve the backend app
COPY docker/gunicorn.conf /etc/gunicorn/gunicorn.conf

# Set up Nginx to proxy requests to Gunicorn
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf

# Expose the necessary ports
EXPOSE 80

# Start Gunicorn and Nginx
CMD ["sh", "-c", "gunicorn -c /etc/gunicorn/gunicorn.conf app:app & nginx -g 'daemon off;'"]
19 changes: 17 additions & 2 deletions docker/README.md
Expand Up @@ -2,25 +2,40 @@

This Docker setup is designed to build the Docker image for the LunchHeroes application, which can then be pushed to a Docker registry and deployed on a server.

# Important Links
- The server is hosted on [Flow Swiss](https://my.flow.swiss/).
- Repo is on DockerHub: [Dockerhub]https://hub.docker.com/repository/docker/lucca93/lunchheroes
- Link to Live App: http://app.lunchhero.ch/ or https://env-9057938.appengine.flow.ch/


## Preliminary Steps

1. **Building the Docker Image**
To build the Docker image, navigate to the directory containing the Dockerfile and run the following command:
To build the Docker image, navigate to the LunchHeroes and run the following command:
```bash
docker build -t lunchheroes -f docker/Dockerfile .
```
Build the Docker Image directly from the Git Repo.
```bash
docker push lucca93/lunchheroes:latest
docker build -t lunchheroes -f docker/Dockerfile_GitConnect .
```

2. **Pushing Docker Image:**
- After building the Docker image, push it to your Docker registry using the following command:
```bash
docker push lucca93/lunchheroes:latest
```
3. **Redeploy Container in FlowEngine**
- Application Server
- Redeploy Container


<<<<<<< HEAD
**Server Hosting:**
- The server is hosted on [Flow Swiss](https://my.flow.swiss/).

=======
>>>>>>> a34e2f1731ef7ab569e9b273a1195ab4729d2df9
## File Descriptions

### Dockerfile
Expand Down

0 comments on commit 140ea96

Please sign in to comment.