Skip to content

Commit

Permalink
Split nodejs into separate build
Browse files Browse the repository at this point in the history
  • Loading branch information
captn3m0 committed Jan 2, 2019
1 parent d0a84eb commit 6d8689a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 58 deletions.
75 changes: 36 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,58 @@
FROM debian:stretch-slim AS build
FROM rust:slim AS build
MAINTAINER Ivan <ivan@zderadicka.eu>

ARG FEATURES

RUN apt -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update &&\
apt-get install -y pkg-config openssl libssl-dev libtag1-dev libtagc0-dev curl yasm build-essential wget libbz2-dev zlib1g-dev &&\
curl -sL https://deb.nodesource.com/setup_8.x | bash - &&\
apt-get install -y nodejs

COPY . /audioserve_src

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

RUN mkdir ffmpeg-static &&\
curl -sL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | tar xJv -C ffmpeg-static --strip-components=1 --wildcards "*/ffmpeg" &&\
cp /ffmpeg-static/ffmpeg /usr/bin
RUN apt-get update && \
apt-get install -y \
curl \
libbz2-dev \
libssl1.0-dev \
libtag1-dev \
libtagc0-dev \
openssl \
pkg-config \
yasm && \
mkdir ffmpeg-static && \
curl -sL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | \
tar xJv -C ffmpeg-static --strip-components=1 --wildcards "*/ffmpeg" && \
mv /ffmpeg-static/ffmpeg /usr/bin/ffmpeg

WORKDIR /src
COPY Cargo.toml Cargo.lock /src/
# To cache this step, we only copy the toml file above
RUN cargo fetch

COPY . /src

RUN cargo build --release ${FEATURES} && \
cargo test --release ${FEATURES}

FROM node:8-alpine as frontend

RUN export PATH=${HOME}/.cargo/bin:$PATH &&\
cd audioserve_src &&\
cargo build --release ${FEATURES} &&\
cargo test --release ${FEATURES}
WORKDIR /src
COPY client /src

RUN cd audioserve_src/client &&\
npm install &&\
RUN npm install && \
npm run build

RUN mkdir /ssl &&\
cd /ssl &&\
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem \
-subj "/C=CZ/ST=Prague/L=Prague/O=Ivan/CN=audioserve" &&\
openssl pkcs12 -inkey key.pem -in certificate.pem -export -passout pass:mypass -out audioserve.p12

FROM debian:stretch-slim

VOLUME /audiobooks
COPY --from=build /audioserve_src/target/release/audioserve /audioserve/audioserve
COPY --from=build /audioserve_src/client/dist /audioserve/client/dist
COPY --from=build /ssl/audioserve.p12 /audioserve/ssl/audioserve.p12
COPY --from=frontend /audioserve_src/client/dist /audioserve/client/dist
COPY --from=build /ffmpeg-static/ffmpeg /usr/bin

RUN adduser audioserve &&\
chown -R audioserve:audioserve /audioserve &&\
apt -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update &&\
RUN adduser audioserve && \
chown -R audioserve:audioserve /audioserve && \
apt -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update && \
apt-get install -y libssl1.1 libtag1v5 libtagc0 libbz2-1.0

WORKDIR /audioserve
USER audioserve

ENV SECRET=mypass
ENV SSLKEY=./ssl/audioserve.p12
ENV SSLPASS=mypass
ENV DIRS=/audiobooks
ENV PORT=3000

EXPOSE ${PORT}

COPY audioserve.sh .

CMD ./audioserve.sh
ENTRYPOINT ["/audioserve/audioserve"]
CMD ["/audiobooks"]
19 changes: 0 additions & 19 deletions audioserve.sh

This file was deleted.

0 comments on commit 6d8689a

Please sign in to comment.