tubo / Dockerfile
soiz1's picture
Update Dockerfile
0ff2302 verified
# Build Stage
FROM clojure:tools-deps AS build
# Clone the Git repository
RUN git clone https://github.com/migalmoreno/tubo /app
WORKDIR /app
# Install Node.js (LTS version) and npm
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
# Set up writable Maven repository directory
ENV MAVEN_REPO=/app/.m2/repository
RUN mkdir -p $MAVEN_REPO && chmod -R 777 $MAVEN_REPO
ENV MAVEN_OPTS="-Dmaven.repo.local=$MAVEN_REPO"
# Set up writable Clojure cache directory
ENV CLOJURE_HOME=/app/.clojure
RUN mkdir -p $CLOJURE_HOME && chmod -R 777 $CLOJURE_HOME
ENV XDG_CACHE_HOME=$CLOJURE_HOME/cache
ENV XDG_CONFIG_HOME=$CLOJURE_HOME/config
# Clean up potential Maven lock files and directories
RUN rm -rf $MAVEN_REPO/metosin/reitit-middleware/
# Automatically update the dependency version in deps.edn
RUN sed -i 's/"metosin\/reitit-middleware" *{:mvn\/version ".*"}/"metosin\/reitit-middleware" {:mvn\/version "0.7.2"}/' deps.edn
# Pull dependencies to pre-cache them
RUN clojure -P
# Install Node.js dependencies
RUN npm install
# Compile the frontend or perform other build tasks
RUN clojure -M:frontend release tubo
# Runtime Stage
FROM clojure:tools-deps
WORKDIR /app
# Install Node.js (LTS version) in the runtime container
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
# Set up writable Maven repository directory in the runtime environment
ENV MAVEN_REPO=/app/.m2/repository
RUN mkdir -p $MAVEN_REPO && chmod -R 777 $MAVEN_REPO
ENV MAVEN_OPTS="-Dmaven.repo.local=$MAVEN_REPO"
# Set up writable Clojure cache directory in the runtime environment
ENV CLOJURE_HOME=/app/.clojure
RUN mkdir -p $CLOJURE_HOME && chmod -R 777 $CLOJURE_HOME
ENV XDG_CACHE_HOME=$CLOJURE_HOME/cache
ENV XDG_CONFIG_HOME=$CLOJURE_HOME/config
# Copy all source files from the build stage
COPY --from=build /app /app
# Clean up potential Maven lock files and directories
#RUN rm -rf $MAVEN_REPO/metosin/reitit-middleware/
# Pull dependencies to ensure a consistent runtime environment
RUN clojure -P
# Compile the Clojure namespace (optional if required by the app)
RUN clojure -M -e "(compile 'tubo.downloader-impl)"
# Expose the port
EXPOSE 3000
# Run the application
CMD ["clojure", "-M:run"]