Skip to content

Commit

Permalink
chore: update Dockerfile to install system dependencies, set up Rust …
Browse files Browse the repository at this point in the history
…and Dioxus CLI, and ensure directory ownership for node user
  • Loading branch information
oceanbluesky committed Nov 22, 2024
1 parent f8129e4 commit 84069dd
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
# syntax=docker/dockerfile:1

ARG NODE_VERSION=23.0.0
FROM node:${NODE_VERSION}-alpine

FROM duel80003/rust-dioxus:latest
# Install necessary system dependencies for Rust and Dioxus CLI
RUN apk add --no-cache curl gcc musl-dev perl make

# Install Rust and Dioxus CLI as root
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable && \
source $HOME/.cargo/env && \
PATH="$HOME/.cargo/bin:$PATH" && \
cargo install dioxus-cli --root /usr/local && \
chmod +x /usr/local/bin/dx

# Update PATH to include Cargo bin directory
ENV PATH="/root/.cargo/bin:/usr/local/bin:${PATH}"

# Ensure all necessary directories are owned by `node`
RUN mkdir -p /root/.cargo /root/.rustup dist/assets/styles target && \
chown -R node:node /root/.cargo /root/.rustup dist target /usr/src/app

# Use production node environment by default
ENV NODE_ENV=production

# Set the working directory
WORKDIR /usr/src/app

# Copy package.json and install dependencies
# Copy package files into the image and install dependencies
COPY package.json package-lock.json ./
RUN npm ci --omit=dev && npm install concurrently tailwindcss --no-save

# Copy the rest of the application code
COPY . .
# Switch to non-root user for running the application
USER node

# Copy the rest of the source files into the image
COPY --chown=node:node . .

# Expose the port for the application
# Expose the port that the application listens on
EXPOSE 8080

# Run the application
CMD ["npm", "run", "serve"]
CMD ["npm", "run", "serve"]

0 comments on commit 84069dd

Please sign in to comment.