Skip to content

Commit

Permalink
chore: update Dockerfile to use nightly Rust image, install Node.js a…
Browse files Browse the repository at this point in the history
…nd dependencies, and adjust build commands for Tailwind CSS and Rust application
  • Loading branch information
oceanbluesky committed Nov 23, 2024
1 parent e70f8c2 commit 58e037f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
51 changes: 37 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
# Use a Rust image with a compatible version
FROM rust:1.73
ARG VARIANT="nightly-bookworm-slim"
FROM rustlang/rust:${VARIANT}

# Set the working directory
WORKDIR /usr/src/myapp
# Suppress interactive prompts in Docker builds
ENV DEBIAN_FRONTEND=noninteractive

# Copy source code into the container
COPY . .
# Install required dependencies, including Node.js and OpenSSL
RUN apt-get update && \
apt-get install -qq -y \
build-essential \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
curl \
pkg-config \
libssl-dev && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -qq -y nodejs && \
npm install -g concurrently && \
apt-get clean

# Set working directory
WORKDIR /app

# Install Node.js and npm for Tailwind CSS
RUN apt-get update && apt-get install -y nodejs npm
# Copy Node.js dependencies for TailwindCSS
COPY package*.json ./

# Install Tailwind CSS and build the CSS file
# Install Node.js dependencies
RUN npm install
RUN npx tailwindcss build -o dist/assets/styles/tailwind.css

# Install dependencies and build the Rust application
RUN cargo update && cargo build --release
# Copy source files into the image
COPY . .

# Build TailwindCSS before building the Rust project
RUN npm run build:css

# Build the Rust project
RUN cargo build --release

# Expose the application port
EXPOSE 8080

# Define the default command
CMD ["./target/release/github_bio"]
# Start the application
CMD ["npm", "run", "serve"]
4 changes: 1 addition & 3 deletions README.Docker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
### Building and running your application

When you're ready, start your application by running:
# When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:3000.
Expand Down
6 changes: 4 additions & 2 deletions __about_these_files.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

1st: npm run serve
2nd: http://localhost:8080
# 1st:
npm run serve
# 2nd:
http://localhost:8080


IF RUNNING VIA DOCKER:
Expand Down

0 comments on commit 58e037f

Please sign in to comment.