Skip to content

Commit d5a33f2

Browse files
fixed docker finally
1 parent 4da5720 commit d5a33f2

File tree

8 files changed

+475
-143
lines changed

8 files changed

+475
-143
lines changed

.dockerignore

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
.git
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.DS_Store
8+
**/__pycache__
9+
**/.venv
10+
**/.classpath
11+
**/.dockerignore
12+
**/.env
13+
**/.git
14+
**/.gitignore
15+
**/.project
16+
**/.settings
17+
**/.toolstarget
18+
**/.vs
19+
**/.vscode
20+
**/*.*proj.user
21+
**/*.dbmdl
22+
**/*.jfm
23+
**/bin
24+
**/charts
25+
**/docker-compose*
26+
**/compose.y*ml
27+
**/Dockerfile*
28+
**/node_modules
29+
**/npm-debug.log
30+
**/obj
31+
**/secrets.dev.yaml
32+
**/values.dev.yaml
33+
LICENSE
34+
README.md

Dockerfile

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,69 @@
1-
# Dockerfile
1+
# syntax=docker/dockerfile:1
22

3-
# Use a base image with Python
4-
FROM python:3.10.14
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/go/dockerfile-reference/
56

6-
# Set environment variables
7-
ENV PYTHONDONTWRITEBYTECODE=1
8-
ENV PYTHONUNBUFFERED=1
7+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
98

10-
# Set the working directory
11-
WORKDIR /app
9+
ARG PYTHON_VERSION=3.10.14
10+
FROM python:${PYTHON_VERSION} as base
1211

13-
# Install system dependencies
14-
RUN apt-get update && \
15-
apt-get install -y jq && \
16-
apt-get clean
12+
# Prevents Python from writing pyc files.
13+
ENV PYTHONDONTWRITEBYTECODE=1
1714

18-
# Copy the Poetry lock files and install Poetry
19-
COPY pyproject.toml poetry.lock ./
20-
RUN pip install poetry && poetry config virtualenvs.create false && poetry install --no-dev
21-
# Install ollama
22-
RUN curl -fsSL https://ollama.com/install.sh | sh
15+
# Keeps Python from buffering stdout and stderr to avoid situations where
16+
# the application crashes without emitting any logs due to buffering.
17+
ENV PYTHONUNBUFFERED=1
2318

24-
RUN ollama serve&
25-
# RUN while [ "$(ollama list | grep 'NAME')" == "" ]; do sleep 1 done
26-
# RUN until ollama list | grep -q 'NAME'; do sleep 1; done
27-
# RUN timeout 120 bash -c 'until ollama list | grep -q "NAME"; do sleep 1; done'
28-
RUN ollama serve & sleep 5 && ollama run llama3
19+
WORKDIR /app
2920

21+
# Create a non-privileged user that the app will run under.
22+
# See https://docs.docker.com/go/dockerfile-user-best-practices/
23+
# ARG UID=10001
24+
# RUN adduser \
25+
# --disabled-password \
26+
# --gecos "" \
27+
# --home "/nonexistent" \
28+
# --shell "/sbin/nologin" \
29+
# --no-create-home \
30+
# --uid "${UID}" \
31+
# appuser
3032

33+
# Download dependencies as a separate step to take advantage of Docker's caching.
34+
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
35+
# Leverage a bind mount to requirements.txt to avoid having to copy them into
36+
# into this layer.
37+
RUN --mount=type=cache,target=/root/.cache/pip \
38+
--mount=type=bind,source=requirements.txt,target=requirements.txt \
39+
python -m pip install -r requirements.txt
3140

32-
# RUN ollama pull llama3
41+
# Switch to the non-privileged user to run the application.
42+
# USER appuser
3343

34-
# Copy the application code
35-
COPY . .
44+
# Copy the source code into the container.
45+
COPY ./data ./data
46+
COPY ./backend ./backend
47+
COPY ./documentation_bot ./documentation_bot
48+
COPY ./frontend ./frontend
49+
COPY ./structured_query ./structured_query
50+
COPY ./ollama ./ollama
51+
COPY ./llm_service ./llm_service
52+
COPY ./start_docker_local.sh ./start_docker_local.sh
53+
COPY ./start_local.sh ./start_local.sh
54+
COPY ./start_training.sh ./start_training.sh
55+
COPY ./stop_docker.sh ./stop_docker.sh
3656

37-
# Expose the necessary ports
38-
EXPOSE 8000 8081 8083 8050 11434 8501
57+
RUN curl -fsSL https://ollama.com/install.sh | sh
58+
RUN ollama serve & sleep 5 && ollama run llama3
59+
# Expose the port that the application listens on.
60+
EXPOSE 8000
61+
EXPOSE 8081
62+
EXPOSE 8083
63+
EXPOSE 8501
64+
EXPOSE 11434
3965

40-
# Start the application
41-
CMD ["bash", "start_docker_local.sh"]
66+
# Run the application.
67+
# CMD uvicorn 'backend.backend:app' --host=0.0.0.0 --port=8000
68+
# CMD [ "ls" ]
69+
CMD [ "./start_docker_local.sh" ]

README.Docker.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Building and running your application
2+
3+
When you're ready, start your application by running:
4+
`docker compose up --build`.
5+
6+
Your application will be available at http://localhost:8000.
7+
8+
### Deploying your application to the cloud
9+
10+
First, build your image, e.g.: `docker build -t myapp .`.
11+
If your cloud uses a different CPU architecture than your development
12+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
13+
you'll want to build the image for that platform, e.g.:
14+
`docker build --platform=linux/amd64 -t myapp .`.
15+
16+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
17+
18+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
19+
docs for more detail on building and pushing.
20+
21+
### References
22+
* [Docker's Python guide](https://docs.docker.com/language/python/)

backend/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

compose.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Docker Compose reference guide at
3+
# https://docs.docker.com/go/compose-spec-reference/
4+
5+
# Here the instructions define your application as a service called "server".
6+
# This service is built from the Dockerfile in the current directory.
7+
# You can add other services your application may depend on here, such as a
8+
# database or a cache. For examples, see the Awesome Compose repository:
9+
# https://github.com/docker/awesome-compose
10+
services:
11+
server:
12+
build:
13+
context: .
14+
ports:
15+
- 8000:8000
16+
- 8081:8081
17+
- 8083:8083
18+
- 8501:8501
19+
- 11434:11434
20+
21+
# The commented out section below is an example of how to define a PostgreSQL
22+
# database that your application can use. `depends_on` tells Docker Compose to
23+
# start the database before your application. The `db-data` volume persists the
24+
# database data between container restarts. The `db-password` secret is used
25+
# to set the database password. You must create `db/password.txt` and add
26+
# a password of your choosing to it before running `docker compose up`.
27+
# depends_on:
28+
# db:
29+
# condition: service_healthy
30+
# db:
31+
# image: postgres
32+
# restart: always
33+
# user: postgres
34+
# secrets:
35+
# - db-password
36+
# volumes:
37+
# - db-data:/var/lib/postgresql/data
38+
# environment:
39+
# - POSTGRES_DB=example
40+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
41+
# expose:
42+
# - 5432
43+
# healthcheck:
44+
# test: [ "CMD", "pg_isready" ]
45+
# interval: 10s
46+
# timeout: 5s
47+
# retries: 5
48+
# volumes:
49+
# db-data:
50+
# secrets:
51+
# db-password:
52+
# file: db/password.txt
53+

docker-compose-old.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)