Skip to content
Merged
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
9 changes: 7 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload

FROM base AS prod
RUN addgroup --system appgroup && adduser --system --group appuser
RUN poetry install --without dev--no-interaction --no-ansi
RUN poetry install --without dev --no-interaction --no-ansi
COPY ./app ./app
COPY alembic.ini ./

RUN printf '#!/bin/bash\nset -e\necho "Running database migrations..."\npoetry run alembic upgrade head\necho "Starting server..."\nexec "$@"\n' > /backend/entrypoint.sh && chmod +x /backend/entrypoint.sh
RUN chown -R appuser:appgroup /backend
# Set HOME for appuser and ensure Poetry doesn't create virtualenvs
ENV HOME=/tmp
ENV POETRY_VIRTUALENVS_CREATE=false
USER appuser
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
ENTRYPOINT ["/backend/entrypoint.sh"]
34 changes: 2 additions & 32 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@ services:
build:
target: prod
command:
[
"/bin/bash",
"./scripts/start.sh",
"uvicorn",
"app.main:app",
"--host",
"0.0.0.0",
"--port",
"8000",
]
["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
environment:
CORS_ORIGINS: ${CORS_ORIGINS:-}
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000,http://127.0.0.1:3000}
restart: always

celery-worker:
Expand All @@ -26,27 +17,6 @@ services:
["poetry", "run", "celery", "-A", "app.celery_app", "worker", "--loglevel=info"]
restart: always

flower:
build:
context: ./backend
target: prod
env_file:
- ./backend/.env
environment:
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-chrono}:${POSTGRES_PASSWORD:-chrono}@db:5432/${POSTGRES_DB:-chrono}
REDIS_URL: ${REDIS_URL:-redis://redis:6379/0}
command:
["poetry", "run", "celery", "-A", "app.celery_app", "flower", "--port=5555"]
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
working_dir: /backend
ports:
- "5555:5555"
restart: always

frontend:
build:
target: prod
Expand Down
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
!.yarn/plugins
!.yarn/releases
!.yarn/versions
.pnpm-store

# testing
/coverage
Expand Down
4 changes: 3 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ WORKDIR /app

RUN corepack enable && corepack prepare pnpm@latest --activate

RUN pnpm config set store-dir /tmp/pnpm-store

COPY package.json pnpm-lock.yaml* ./

# Development stage
Expand All @@ -21,7 +23,7 @@ ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN pnpm build

FROM base AS prod
RUN addgroup -S appgroup && adduser -S -G appgroup
RUN addgroup -S appgroup && adduser -S -G appgroup appuser
RUN pnpm install --frozen-lockfile --prod
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
Expand Down