Update Dockerfile for correct directory structure
Browse files- .dockerignore +50 -7
- Dockerfile +17 -20
.dockerignore
CHANGED
@@ -1,10 +1,53 @@
|
|
|
|
1 |
.git
|
2 |
.gitignore
|
3 |
-
|
|
|
|
|
4 |
**/node_modules
|
5 |
-
|
6 |
-
|
7 |
-
.
|
8 |
-
.
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Version control
|
2 |
.git
|
3 |
.gitignore
|
4 |
+
.gitattributes
|
5 |
+
|
6 |
+
# Dependencies
|
7 |
**/node_modules
|
8 |
+
**/.pnp
|
9 |
+
**/.pnp.js
|
10 |
+
**/yarn.lock
|
11 |
+
**/package-lock.json
|
12 |
+
|
13 |
+
# Testing
|
14 |
+
**/coverage
|
15 |
+
|
16 |
+
# Next.js
|
17 |
+
**/.next/
|
18 |
+
**/out/
|
19 |
+
**/build
|
20 |
+
**/.swc/
|
21 |
+
|
22 |
+
# Python
|
23 |
+
**/__pycache__/
|
24 |
+
**/*.py[cod]
|
25 |
+
**/*$py.class
|
26 |
+
**/*.so
|
27 |
+
**/.Python
|
28 |
+
**/env/
|
29 |
+
**/build/
|
30 |
+
**/develop-eggs/
|
31 |
+
**/dist/
|
32 |
+
**/downloads/
|
33 |
+
**/eggs/
|
34 |
+
**/.eggs/
|
35 |
+
**/lib/
|
36 |
+
**/lib64/
|
37 |
+
**/parts/
|
38 |
+
**/sdist/
|
39 |
+
**/var/
|
40 |
+
**/wheels/
|
41 |
+
**/*.egg-info/
|
42 |
+
**/.installed.cfg
|
43 |
+
**/*.egg
|
44 |
+
|
45 |
+
# IDE
|
46 |
+
.idea
|
47 |
+
.vscode
|
48 |
+
*.swp
|
49 |
+
*.swo
|
50 |
+
|
51 |
+
# OS
|
52 |
+
.DS_Store
|
53 |
+
Thumbs.db
|
Dockerfile
CHANGED
@@ -3,11 +3,6 @@
|
|
3 |
# ============================================
|
4 |
FROM node:20.11-alpine3.19 AS base
|
5 |
|
6 |
-
# Use BuildKit's cache mount to speed up installations
|
7 |
-
RUN --mount=type=cache,target=/root/.npm \
|
8 |
-
npm set cache /root/.npm && \
|
9 |
-
npm install -g pnpm
|
10 |
-
|
11 |
# Configure build environment with optimized settings
|
12 |
ENV NODE_OPTIONS="--max_old_space_size=3072" \
|
13 |
NEXT_TELEMETRY_DISABLED=1 \
|
@@ -19,30 +14,31 @@ ENV NODE_OPTIONS="--max_old_space_size=3072" \
|
|
19 |
# ============================================
|
20 |
FROM base AS deps
|
21 |
|
22 |
-
WORKDIR /app
|
23 |
|
24 |
# Copy only package files for better caching
|
25 |
-
COPY
|
26 |
|
27 |
-
# Use
|
28 |
-
RUN --mount=type=cache,target=/
|
29 |
-
|
|
|
30 |
|
31 |
# ============================================
|
32 |
# Builder stage - builds Next.js application
|
33 |
# ============================================
|
34 |
FROM deps AS web-builder
|
35 |
|
36 |
-
WORKDIR /app
|
37 |
|
38 |
# Copy source files
|
39 |
-
COPY
|
40 |
|
41 |
# Install dev dependencies needed for build
|
42 |
-
RUN
|
43 |
|
44 |
# Build with standalone output
|
45 |
-
RUN
|
46 |
|
47 |
# ============================================
|
48 |
# Python builder stage - builds Python deps
|
@@ -55,14 +51,14 @@ RUN apt-get update && \
|
|
55 |
build-essential \
|
56 |
&& rm -rf /var/lib/apt/lists/*
|
57 |
|
58 |
-
WORKDIR /app
|
59 |
|
60 |
# Use BuildKit's cache mount for pip
|
61 |
RUN --mount=type=cache,target=/root/.cache/pip \
|
62 |
pip install --no-cache-dir poetry
|
63 |
|
64 |
# Copy and install Python dependencies
|
65 |
-
COPY
|
66 |
RUN poetry config virtualenvs.create false && \
|
67 |
poetry install --no-dev --no-interaction --no-ansi
|
68 |
|
@@ -79,6 +75,7 @@ RUN apt-get update && \
|
|
79 |
apt-get install -y --no-install-recommends \
|
80 |
nodejs \
|
81 |
npm \
|
|
|
82 |
&& rm -rf /var/lib/apt/lists/*
|
83 |
|
84 |
# Set up directory structure
|
@@ -96,12 +93,12 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|
96 |
|
97 |
# Copy built files from previous stages
|
98 |
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
99 |
-
COPY --chown=user
|
100 |
|
101 |
# Copy Next.js standalone build
|
102 |
-
COPY --from=web-builder --chown=user /app
|
103 |
-
COPY --from=web-builder --chown=user /app
|
104 |
-
COPY --from=web-builder --chown=user /app/
|
105 |
|
106 |
# Set environment variables
|
107 |
ENV FLASK_APP=app.py \
|
|
|
3 |
# ============================================
|
4 |
FROM node:20.11-alpine3.19 AS base
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
# Configure build environment with optimized settings
|
7 |
ENV NODE_OPTIONS="--max_old_space_size=3072" \
|
8 |
NEXT_TELEMETRY_DISABLED=1 \
|
|
|
14 |
# ============================================
|
15 |
FROM base AS deps
|
16 |
|
17 |
+
WORKDIR /app
|
18 |
|
19 |
# Copy only package files for better caching
|
20 |
+
COPY package.json yarn.lock ./
|
21 |
|
22 |
+
# Use yarn with cache for faster installs
|
23 |
+
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
|
24 |
+
yarn config set cache-folder /usr/local/share/.cache/yarn && \
|
25 |
+
yarn install --frozen-lockfile --network-timeout 300000
|
26 |
|
27 |
# ============================================
|
28 |
# Builder stage - builds Next.js application
|
29 |
# ============================================
|
30 |
FROM deps AS web-builder
|
31 |
|
32 |
+
WORKDIR /app
|
33 |
|
34 |
# Copy source files
|
35 |
+
COPY . .
|
36 |
|
37 |
# Install dev dependencies needed for build
|
38 |
+
RUN yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin
|
39 |
|
40 |
# Build with standalone output
|
41 |
+
RUN yarn build
|
42 |
|
43 |
# ============================================
|
44 |
# Python builder stage - builds Python deps
|
|
|
51 |
build-essential \
|
52 |
&& rm -rf /var/lib/apt/lists/*
|
53 |
|
54 |
+
WORKDIR /app
|
55 |
|
56 |
# Use BuildKit's cache mount for pip
|
57 |
RUN --mount=type=cache,target=/root/.cache/pip \
|
58 |
pip install --no-cache-dir poetry
|
59 |
|
60 |
# Copy and install Python dependencies
|
61 |
+
COPY pyproject.toml poetry.lock ./
|
62 |
RUN poetry config virtualenvs.create false && \
|
63 |
poetry install --no-dev --no-interaction --no-ansi
|
64 |
|
|
|
75 |
apt-get install -y --no-install-recommends \
|
76 |
nodejs \
|
77 |
npm \
|
78 |
+
curl \
|
79 |
&& rm -rf /var/lib/apt/lists/*
|
80 |
|
81 |
# Set up directory structure
|
|
|
93 |
|
94 |
# Copy built files from previous stages
|
95 |
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
96 |
+
COPY --chown=user . /app/
|
97 |
|
98 |
# Copy Next.js standalone build
|
99 |
+
COPY --from=web-builder --chown=user /app/.next/standalone /app/web
|
100 |
+
COPY --from=web-builder --chown=user /app/.next/static /app/web/.next/static
|
101 |
+
COPY --from=web-builder --chown=user /app/public /app/web/public
|
102 |
|
103 |
# Set environment variables
|
104 |
ENV FLASK_APP=app.py \
|