File size: 2,377 Bytes
b123d5e
 
ea73822
a9cccd3
86b58fd
8d7e59c
ea73822
0e13590
 
 
 
 
 
a5d3917
 
 
0eb6dd2
a5d3917
2e9c054
 
 
 
 
 
180604e
0eb6dd2
d1139cf
b54cedc
 
1f4109c
0eb6dd2
 
84ca537
0e13590
ea73822
 
180604e
ea73822
 
b123d5e
ea73822
8d7e59c
a9cccd3
 
180604e
0e13590
 
 
 
a5d3917
 
 
0eb6dd2
a5d3917
2e9c054
 
 
 
 
 
2f6199b
 
 
180604e
0ff2302
a5d3917
180604e
0eb6dd2
ea73822
180604e
ea73822
8d7e59c
a9cccd3
ea73822
 
a9cccd3
b123d5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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"]