-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
55 lines (51 loc) · 1.91 KB
/
Dockerfile
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
FROM rust:1.47.0-slim AS runtime
ARG MUOXI_INSTALL_DIR=/opt/muoxi
ENV LANG=C.UTF-8 MUOXI_INSTALL_DIR=${MUOXI_INSTALL_DIR}
WORKDIR ${MUOXI_INSTALL_DIR}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https software-properties-common \
ca-certificates \
libpq5 \
openssl \
curl \
tzdata && \
rm -rf /var/lib/apt/lists/*
RUN export DOCKERIZE_VERSION=v0.6.1 && curl -L \
https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
| tar -C /usr/local/bin -xz
FROM runtime AS builder
ARG MUOXI_UID=1000
ARG MUOXI_USERNAME=you
ENV MUOXI_UID=${MUOXI_UID}
COPY . ${MUOXI_INSTALL_DIR}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
libpq-dev && \
rm -rf /var/lib/apt/lists/* && \
useradd -r -M -u ${MUOXI_UID} -d ${MUOXI_INSTALL_DIR} -c "MuOxi user,,," ${MUOXI_USERNAME} && \
chown -R $MUOXI_UID ${MUOXI_INSTALL_DIR}
USER ${MUOXI_UID}
RUN \
cargo install diesel_cli --no-default-features --features postgres && \
cargo install --path=${MUOXI_INSTALL_DIR}/muoxi
CMD [ "cargo", "run", "--bin", "muoxi_staging" ]
FROM runtime AS release
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder --chown=nobody:nogroup ${MUOXI_INSTALL_DIR} ${MUOXI_INSTALL_DIR}
USER nobody
CMD [ "cargo", "run", "--bin", " muoxi_web" ]
ARG SOURCE_BRANCH="master"
ARG SOURCE_COMMIT="000000"
ARG BUILD_DATE="2020-10-11T12:53:26Z"
ARG IMAGE_NAME="MuOxi:latest"
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="MuOxi" \
org.label-schema.description="MuOxi" \
org.label-schema.vcs-url="https://github.com/duysqubix/MuOxi.git" \
org.label-schema.vcs-ref=$SOURCE_COMMIT \
org.label-schema.schema-version="1.0.0-rc1" \
build-target="release" \
build-branch=$SOURCE_BRANCH