Skip to content

Commit

Permalink
chore(docker): move all docker stages into root dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Sep 27, 2023
1 parent 101da32 commit 988fbc8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
.gitignore
.dockerignore
.editorconfig
.flake8
.commitlintrc.json
Dockerfile
pip-log.txt
*.md
*.pyc
*.pyd
*.pyo

.github
.husky
.vscode

**/.mypy_cache
**/__pycache__
**/node_modules
**/dist
**/build
34 changes: 31 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:lts-alpine AS base
FROM node:lts-alpine AS web-base

WORKDIR /workspace

Expand All @@ -23,11 +23,39 @@ RUN --mount=type=cache,target=/tmp/cache \
EXPOSE 5173

# In development we expose the Vite hot reload port and install all dependencies
FROM base AS development
FROM web-base AS web-development
EXPOSE 24678
CMD [ "pnpm", "web", "dev", "--host" ]

# In production we run the build version of code without hot reload
FROM base AS production
FROM web-base AS web-production
RUN pnpm web build
CMD [ "pnpm", "web", "preview", "--host", "--port=5173" ]


FROM python:3.11 AS api-base

# Ensure FFMPEG is available
RUN apt-get update -y
RUN apt-get install -y ffmpeg

WORKDIR /workspace/api

# Install required python packages
COPY ./apps/api/requirements.txt /workspace/api/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy over source and config files
COPY ./apps/api/app /workspace/api/app
COPY ./apps/api/pyproject.toml /workspace/api/pyproject.toml

# Expose port we are running the api on
EXPOSE 8080

# In development run the application with reload active
FROM api-base AS api-development
CMD [ "uvicorn", "app.main:app", "--host=0.0.0.0", "--port=8080", "--reload" ]

# In production run the application without reload
FROM api-base AS api-production
CMD [ "uvicorn", "app.main:app", "--host=0.0.0.0", "--port=8080" ]
8 changes: 0 additions & 8 deletions apps/api/.dockerignore

This file was deleted.

26 changes: 0 additions & 26 deletions apps/api/Dockerfile

This file was deleted.

6 changes: 3 additions & 3 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ services:
file: docker-compose.yml
service: api
build:
target: development
target: api-development
volumes:
- ./apps/api:/workspace
- ./apps/api:/workspace/api
web:
extends:
file: docker-compose.yml
service: web
build:
target: development
target: web-development
ports:
- 5173:5173
- 24678:24678
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version: '3'
services:
api:
build:
context: ./apps/api
target: production
context: .
target: api-production
image: yd/api:latest
restart: always
environment:
Expand All @@ -14,7 +14,7 @@ services:
web:
build:
context: .
target: production
target: web-production
image: yd/web:latest
restart: always
environment:
Expand Down

1 comment on commit 988fbc8

@vercel
Copy link

@vercel vercel bot commented on 988fbc8 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.