diff --git a/Dockerfile b/Dockerfile index b5e8c4f..b3385bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ # syntax=docker/dockerfile:1 -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/go/dockerfile-reference/ - -# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 - ARG NODE_VERSION=23.0.0 - FROM node:${NODE_VERSION}-alpine -# Use production node environment by default. +# Install Rust and Dioxus CLI for running `dx` commands +RUN apk add --no-cache curl gcc musl-dev && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + source $HOME/.cargo/env && \ + cargo install dioxus-cli + +# Use production node environment by default ENV NODE_ENV=production WORKDIR /usr/src/app @@ -18,26 +17,23 @@ WORKDIR /usr/src/app # Copy package files into the image COPY package.json package-lock.json ./ -# Install all dependencies +# Install all dependencies (omit dev dependencies for production) RUN npm ci --omit=dev -# Download dependencies as a separate step to take advantage of Docker's caching. -# Leverage a cache mount to /root/.npm to speed up subsequent builds. -# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into -# into this layer. -RUN --mount=type=bind,source=package.json,target=package.json \ - --mount=type=bind,source=package-lock.json,target=package-lock.json \ - --mount=type=cache,target=/root/.npm \ - npm ci --omit=dev +# Install specific devDependencies needed for `serve` script +RUN npm install concurrently tailwindcss --no-save + +# Create the `dist` directory with proper permissions +RUN mkdir -p dist/assets/styles && chown -R node:node dist -# Run the application as a non-root user. +# Run the application as a non-root user USER node -# Copy the rest of the source files into the image. +# Copy the rest of the source files into the image COPY . . -# Expose the port that the application listens on. +# Expose the port that the application listens on EXPOSE 8080 -# Run the application. +# Run the application CMD ["npm", "run", "serve"]