Fixing up docker a little bit
This commit is contained in:
parent
3ffa4e144d
commit
a08f0332bc
|
@ -2,5 +2,4 @@ server/ui/node_modules
|
|||
server/ui/dist
|
||||
server/service/target
|
||||
new_torrents_fetcher
|
||||
scripts
|
||||
.git
|
52
Dockerfile
52
Dockerfile
|
@ -1,29 +1,39 @@
|
|||
# Torrents.csv Dockerfile
|
||||
FROM node:10-jessie as node
|
||||
#If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy'
|
||||
|
||||
# Build front end resources
|
||||
FROM node:10 AS node-builder
|
||||
ENV TORRENTS_CSV_ENDPOINT=http://0.0.0.0:8080
|
||||
COPY server/ui /app/server/ui
|
||||
RUN cd /app/server/ui && yarn && yarn build
|
||||
|
||||
ARG UI_PATH=/usr/app/server/ui
|
||||
COPY server/ui ${UI_PATH}
|
||||
WORKDIR ${UI_PATH}
|
||||
ARG ENDPOINT_NAME=0.0.0.0:8080
|
||||
FROM rust:1.30 as rust
|
||||
COPY server/service /app/server/service
|
||||
RUN cd /app/server/service && cargo build --release && cp ./target/release/torrents-csv-service .
|
||||
|
||||
RUN echo "export const endpoint = '${ENDPOINT_NAME}';" > src/env.ts
|
||||
RUN yarn
|
||||
RUN yarn build
|
||||
FROM debian:jessie-slim as volume
|
||||
|
||||
# Build back end
|
||||
FROM rust:1.30
|
||||
COPY torrents.csv /db/
|
||||
|
||||
# Copy the torrents.csv file
|
||||
COPY torrents.csv /usr/app/
|
||||
FROM debian:jessie-slim
|
||||
|
||||
# Creating a directory to work from
|
||||
ARG SERVICE_PATH=/usr/app/server/service
|
||||
COPY server/service ${SERVICE_PATH}
|
||||
WORKDIR ${SERVICE_PATH}
|
||||
RUN apt update && apt install -y sqlite3
|
||||
|
||||
COPY --from=node-builder /usr/app/server/ui /usr/app/server/ui
|
||||
COPY --from=node /app/server/ui/dist /app/dist
|
||||
COPY --from=rust /app/server/service/target/release/torrents-csv-service /app/
|
||||
COPY --from=volume /db/torrents.csv /app/
|
||||
COPY scripts /app/scripts
|
||||
RUN cd /app/scripts && . ./build_sqlite.sh
|
||||
|
||||
# Build it
|
||||
RUN cargo build --release
|
||||
EXPOSE 8080
|
||||
WORKDIR /app/
|
||||
|
||||
ENV TORRENTS_CSV_DB_FILE=/app/torrents.db
|
||||
ENV TORRENTS_CSV_FRONT_END_DIR=/app/dist
|
||||
|
||||
RUN sqlite3 ${TORRENTS_CSV_DB_FILE} 'select * from torrents limit 10'
|
||||
|
||||
CMD /app/torrents-csv-service
|
||||
|
||||
# Running this:
|
||||
|
||||
# docker build .
|
||||
# docker run -p 8080:8080 image_name
|
|
@ -1,16 +1,18 @@
|
|||
#!/bin/bash
|
||||
csv_file="${TORRENTS_CSV_FILE:-../torrents.csv}"
|
||||
db_file="${TORRENTS_CSV_DB_FILE:-../torrents.db}"
|
||||
|
||||
echo "Creating temporary torrents.db file..."
|
||||
|
||||
# Remove double quotes for csv import
|
||||
sed 's/\"//g' ../torrents.csv > torrents_removed_quotes.csv
|
||||
sed 's/\"//g' $csv_file > torrents_removed_quotes.csv
|
||||
|
||||
# Sort by seeders desc before insert
|
||||
sort --field-separator=';' --key=5 -nr -o torrents_removed_quotes.csv torrents_removed_quotes.csv
|
||||
|
||||
rm ../torrents.db
|
||||
rm $db_file
|
||||
|
||||
sqlite3 -batch ../torrents.db <<"EOF"
|
||||
sqlite3 -batch $db_file <<"EOF"
|
||||
create table torrents(
|
||||
"infohash" TEXT,
|
||||
"name" TEXT,
|
||||
|
@ -24,8 +26,8 @@ create table torrents(
|
|||
.separator ";"
|
||||
.import torrents_removed_quotes.csv torrents
|
||||
UPDATE torrents SET completed=NULL WHERE completed = '';
|
||||
|
||||
EOF
|
||||
|
||||
rm torrents_removed_quotes.csv
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Optionally use environment variables
|
||||
|
||||
# export TORRENTS_CSV_ENDPOINT=http://0.0.0.0:8080
|
||||
# export TORRENTS_CSV_FILE=`pwd`/../../torrents.db
|
||||
# export TORRENTS_CSV_DB_FILE=`pwd`/../../torrents.db
|
||||
# export TORRENTS_CSV_FRONT_END_DIR=`pwd`/../ui/dist
|
||||
|
||||
|
|
Loading…
Reference in New Issue