-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rebuild docker image and github workflow
- Loading branch information
1 parent
ed1f2c2
commit 8448f27
Showing
4 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
# Use the official Rust image as the base image | ||
FROM rust:latest AS builder | ||
# Start with the official Rust image | ||
FROM rust:1.71-slim-buster AS builder | ||
|
||
# Install required dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
pkg-config \ | ||
libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a new empty shell project | ||
RUN USER=root cargo new --bin spotify | ||
WORKDIR /spotify | ||
|
||
# Copy the Cargo.toml and Cargo.lock files | ||
COPY Cargo.toml Cargo.lock ./ | ||
# Copy the Cargo.toml and Cargo.lock if it exists | ||
COPY Cargo.toml Cargo.toml | ||
COPY Cargo.lock Cargo.lock | ||
|
||
# Copy the source code | ||
COPY src ./src | ||
COPY src src | ||
|
||
# Build the dependencies only | ||
RUN cargo build --release | ||
|
||
# Copy the source code again to ensure it's up to date | ||
COPY . . | ||
|
||
# Build the application in release mode | ||
# Build the application | ||
RUN cargo build --release | ||
|
||
# Use the official Debian image as the base image for the runtime | ||
# Use a minimal base image for the final stage | ||
FROM debian:buster-slim | ||
|
||
# Copy the compiled binary from the builder stage | ||
# Install required runtime dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
libssl1.1 \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the built binary from the builder stage | ||
COPY --from=builder /spotify/target/release/spotify /usr/local/bin/spotify | ||
|
||
# Expose port 7860 | ||
# Copy the static files to the final image | ||
COPY src/static /usr/local/bin/static | ||
|
||
# Copy environment variables from build arguments to the runtime environment | ||
ARG SPOTIFY_CLIENT_ID | ||
ARG SPOTIFY_CLIENT_SECRET | ||
ARG SPOTIFY_PLAYLIST_ID | ||
|
||
ENV SPOTIFY_CLIENT_ID=$SPOTIFY_CLIENT_ID | ||
ENV SPOTIFY_CLIENT_SECRET=$SPOTIFY_CLIENT_SECRET | ||
ENV SPOTIFY_PLAYLIST_ID=$SPOTIFY_PLAYLIST_ID | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 7860 | ||
|
||
# Run the application | ||
# Set the default command to run the application | ||
CMD ["spotify"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters