Skip to content

Commit

Permalink
chore: update Dockerfile to install Rust and Dioxus CLI, and add nece…
Browse files Browse the repository at this point in the history
…ssary devDependencies
  • Loading branch information
oceanbluesky committed Nov 16, 2024
1 parent 515cf05 commit 752709e
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
# 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

# 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"]

0 comments on commit 752709e

Please sign in to comment.