Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDEX dockerfile uses turbo #7164

Merged
merged 3 commits into from
Jan 11, 2024
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
4 changes: 2 additions & 2 deletions dev-tools/compose/docker-compose.ddex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ services:
ddex:
container_name: ddex
build:
context: ${PROJECT_ROOT}/packages
dockerfile: Dockerfile.ddex
context: ${PROJECT_ROOT}
dockerfile: ${PROJECT_ROOT}/packages/Dockerfile.ddex
args:
app_name: ddex
TURBO_TEAM: '${TURBO_TEAM}'
Expand Down
65 changes: 51 additions & 14 deletions packages/Dockerfile.ddex
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
# Build stage for DDEX frontend
FROM node:18.17-slim AS frontend-dist

ARG TURBO_TEAM
ENV TURBO_TEAM=$TURBO_TEAM

ARG TURBO_TOKEN
ENV TURBO_TOKEN=$TURBO_TOKEN

WORKDIR /app

RUN npm install turbo --global
COPY . .
RUN turbo prune --scope=@audius/ddex-frontend --docker

RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
make \
g++ \
curl \
bash \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY ddex-frontend/package*.json ddex-frontend/*config*.js ddex-frontend/tsconfig*.json ddex-frontend/vite.config.ts ./
RUN npm install
COPY ddex-frontend/src ./src
COPY ddex-frontend/public ./public
COPY ddex-frontend/index.html .
RUN npm run build

RUN CI=true npm i

# Build the project and its dependencies
COPY turbo.json turbo.json
RUN npx turbo run build --filter=@audius/ddex-frontend

# Build stage for DDEX backend
FROM node:18.17-slim AS backend-dist

ARG TURBO_TEAM
ENV TURBO_TEAM=$TURBO_TEAM

ARG TURBO_TOKEN
ENV TURBO_TOKEN=$TURBO_TOKEN

WORKDIR /backend
COPY ddex/package*.json ddex/tsconfig.json ./
RUN npm install
COPY ddex/src ./src
RUN npm run build

RUN npm install turbo --global
COPY . .
RUN turbo prune --scope=@audius/ddex --docker

RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
make \
g++ \
curl \
bash \
&& rm -rf /var/lib/apt/lists/*

RUN CI=true npm i

# Build the project and its dependencies
COPY turbo.json turbo.json
RUN npx turbo run build --filter=@audius/ddex

# Final stage
FROM node:18.17-slim
WORKDIR /usr/src/app
COPY --from=frontend-dist /app/dist ./public
COPY --from=backend-dist /backend/dist ./dist
COPY --from=backend-dist /backend/node_modules ./node_modules
COPY --from=frontend-dist /app/packages/ddex-frontend/dist ./public
COPY --from=backend-dist /backend/packages/ddex/dist ./dist
COPY --from=backend-dist /backend/packages/ddex/node_modules ./node_modules

EXPOSE 8926
CMD [ "node", "dist/index.js" ]
29 changes: 22 additions & 7 deletions packages/Dockerfile.ddex.fast
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,34 @@
# Build DDEX backend
FROM node:18.17-slim AS backend-dist
WORKDIR /backend
COPY ddex/package*.json ddex/tsconfig.json ./
RUN npm install
COPY ddex/src ./src
RUN npm run build
# COPY packages/ddex/package*.json packages/ddex/tsconfig.json ./
# COPY packages/ddex/src ./src

RUN npm install turbo --global
COPY . .
RUN turbo prune --scope=@audius/ddex --docker

RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
make \
g++ \
curl \
bash \
&& rm -rf /var/lib/apt/lists/*

RUN CI=true npm i
COPY turbo.json turbo.json
RUN npx turbo run build --filter=@audius/ddex

# Final stage
FROM node:18.17-slim
WORKDIR /usr/src/app
COPY --from=backend-dist /backend/dist ./dist
COPY --from=backend-dist /backend/node_modules ./node_modules
COPY --from=backend-dist /backend/packages/ddex/dist ./dist
COPY --from=backend-dist /backend/packages/ddex/node_modules ./node_modules

# Copy the frontend dist from local filesystem instead of building it in Docker, which hangs
COPY ddex-frontend/dist/ ./public
COPY packages/ddex-frontend/dist/ ./public

EXPOSE 8926
CMD [ "node", "dist/index.js" ]