soiz commited on
Commit
929b970
·
verified ·
1 Parent(s): 4320474

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +61 -0
Dockerfile ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base image with Crystal and dependencies
2
+ FROM crystallang/crystal:1.4.1-alpine AS builder
3
+ RUN apk add --no-cache sqlite-static yaml-static git curl
4
+
5
+ # Clone the repository
6
+ WORKDIR /invidious
7
+ RUN git clone https://github.com/yewtudotbe/invidious-custom.git .
8
+
9
+ # Remove old shards cache if exists
10
+ RUN rm -rf ~/.cache/crystal/shards
11
+
12
+ # Download shard.yml from the provided URL
13
+ RUN curl -fsSL "https://huggingface.co/spaces/soiz/invidious5/raw/main/test-file-001/shard.yml" -o ./shard.yml
14
+
15
+ # Remove invalid shard.lock if exists
16
+ RUN rm -f ./shard.lock
17
+
18
+ # Install dependencies (including kemal)
19
+ RUN shards install --ignore-crystal-version
20
+
21
+ # Create the src directory (if it doesn't exist) before downloading invidious.cr
22
+ RUN mkdir -p ./src
23
+
24
+ # Download the invidious.cr from the specified URL into the src directory
25
+ RUN curl -fsSL "https://huggingface.co/spaces/soiz/invidious5/raw/main/test-file-001/invidious.cr" -o ./src/invidious.cr
26
+
27
+ # Ensure dependencies are installed after the new invidious.cr is added
28
+ RUN shards install
29
+
30
+ # Build the application
31
+ WORKDIR /invidious/src
32
+ RUN crystal build --release invidious.cr \
33
+ --static --warnings all \
34
+ --link-flags "-lxml2 -llzma"
35
+
36
+ # Final runtime image
37
+ FROM alpine:latest
38
+ RUN apk add --no-cache librsvg ttf-opensans tini curl
39
+ WORKDIR /invidious
40
+ RUN addgroup -g 1000 -S invidious && \
41
+ adduser -u 1000 -S invidious -G invidious
42
+
43
+ # Add config.example.yml from remote URL
44
+ RUN mkdir -p ./config
45
+ RUN curl -fsSL "https://raw.githubusercontent.com/iv-org/invidious/refs/heads/master/config/config.example.yml" -o ./config/config.example.yml
46
+
47
+ # Use config.example.yml as default configuration
48
+ RUN mv -n ./config/config.example.yml ./config/config.yml
49
+
50
+ # Ensure necessary files
51
+ COPY --from=builder /invidious/assets ./assets/
52
+ COPY --from=builder /invidious/invidious .
53
+ RUN chmod o+rX -R ./assets ./config ./locales
54
+
55
+ # Expose application port
56
+ EXPOSE 3000
57
+
58
+ # Set user and entrypoint
59
+ USER invidious
60
+ ENTRYPOINT ["/sbin/tini", "--"]
61
+ CMD [ "/invidious/invidious" ]