-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dockerfile, docker-compose, updated docs * small updates to settings.py and test settings to improve coverage in CI * updated docs to reflect docker compose vs. the old start.sh method * updated node version in .nvmrc
- Loading branch information
1 parent
67ea498
commit 3c35b37
Showing
12 changed files
with
149 additions
and
103 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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 +1 @@ | ||
v20.10.0 | ||
20.15.1 |
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,82 @@ | ||
# Build stage | ||
FROM python:3.12.4 as builder | ||
|
||
WORKDIR /app | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl \ | ||
build-essential \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Python dependencies | ||
COPY requirements /app/requirements | ||
RUN pip install --no-cache-dir -r requirements/dev.txt | ||
|
||
# Install NVM and Node.js | ||
ENV NVM_DIR /root/.nvm | ||
# This should match the version referenced below in the Run stage, and in entrypoint.sh | ||
ENV NODE_VERSION 20.15.1 | ||
|
||
COPY package.json package-lock.json /app/ | ||
|
||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \ | ||
&& . "$NVM_DIR/nvm.sh" \ | ||
&& nvm install ${NODE_VERSION} \ | ||
&& nvm use v${NODE_VERSION} \ | ||
&& nvm alias default v${NODE_VERSION} \ | ||
&& npm install | ||
|
||
|
||
# Runtime stage | ||
FROM python:3.12.4 | ||
|
||
WORKDIR /app | ||
|
||
# Copy Python environment from builder | ||
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages | ||
COPY --from=builder /usr/local/bin /usr/local/bin | ||
|
||
# Copy Node.js environment from builder | ||
COPY --from=builder /root/.nvm /root/.nvm | ||
ENV NVM_DIR /root/.nvm | ||
|
||
# The version in this path should match the version referenced above in the Run stage, and in entrypoint.sh | ||
ENV PATH $NVM_DIR/versions/node/v20.15.1/bin:$PATH | ||
|
||
COPY --from=builder /app/node_modules /app/node_modules | ||
|
||
COPY . /app | ||
|
||
# Run migrations and create initial data | ||
RUN python manage.py migrate && \ | ||
python manage.py shell <<ORM | ||
from django.contrib.auth.models import User | ||
u = User.objects.filter(username='admin').first() | ||
if not u: | ||
u = User(username='admin') | ||
u.set_password('admin') | ||
u.is_superuser = True | ||
u.is_staff = True | ||
u.save() | ||
|
||
from explorer.models import Query | ||
queries = Query.objects.all().count() | ||
if queries == 0: | ||
q = Query(sql='select * from explorer_query;', title='Sample Query') | ||
q.save() | ||
ORM | ||
|
||
# Copy and set permissions for the entrypoint script | ||
COPY --chown=myuser:myuser entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
# Expose the ports the app runs on | ||
EXPOSE 8000 5173 | ||
|
||
# Health check | ||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | ||
CMD curl -f http://localhost:8000/ || exit 1 | ||
|
||
# Set the entrypoint | ||
ENTRYPOINT ["/entrypoint.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
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,15 @@ | ||
services: | ||
web: | ||
build: . | ||
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"] | ||
ports: | ||
- "8000:8000" | ||
- "5173:5173" | ||
volumes: | ||
- .:/app | ||
- node_modules:/app/node_modules | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=test_project.settings | ||
|
||
volumes: | ||
node_modules: |
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
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
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,19 @@ | ||
#!/bin/bash | ||
# entrypoint.sh | ||
|
||
set -e | ||
|
||
# Source the nvm script to set up the environment | ||
# This should match the version referenced in Dockerfile | ||
. /root/.nvm/nvm.sh | ||
nvm use 20.15.1 | ||
|
||
# Django | ||
python manage.py migrate | ||
python manage.py runserver 0.0.0.0:8000 & | ||
echo "Django server started" | ||
|
||
# Vite dev server | ||
export APP_VERSION=$(python -c 'from explorer import __version__; print(__version__)') | ||
echo "Starting Vite with APP_VERSION=${APP_VERSION}" | ||
npx vite --config vite.config.mjs |
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
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
This file was deleted.
Oops, something went wrong.
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