-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
77 lines (60 loc) · 1.67 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM rust:1.80.1-slim AS stage-basic
# --------------------------------
# ARGUMENTS
# --------------------------------
ARG USER
ARG APP
ARG WD
ARG HTTP_IP
ARG HTTP_PORT
ARG HTTP_USER
ARG HTTP_PASSWORD
# --------------------------------
# SET USERS, ACCESS
# --------------------------------
# Create a non-privileged user to run the service.
RUN groupadd --gid 999 ${USER} \
&& useradd --uid 1001 --gid 999 --create-home ${USER}
# Running instance should own the code, as task automation leads to changes.
COPY . ${WD}
RUN chown -R ${USER}:${USER} ${WD}
USER root
WORKDIR ${WD}
COPY . .
FROM stage-basic AS stage1
# --------------------------------
# INSTALL EXTRAS
# --------------------------------
# install curl + xz-unzip
RUN apt-get clean
RUN apt-get update
RUN apt-get install -y curl xz-utils
RUN apt-get clean
# zig (for cargo-zigbuild)
RUN curl -sS https://webi.sh/zig | sh
ENV PATH "~/.local/bin:$PATH"
ENV PATH "~/.local/opt/zig:$PATH"
RUN bash -c "zig version"
# just, zigbuild (for crossplatform compilation in rust!)
RUN cargo install --locked just
RUN cargo install --locked cargo-zigbuild
FROM stage1 AS stage2
# --------------------------------
# PROJECT BUILD
# --------------------------------
RUN just setup
RUN echo "\n\
ARTEFACT_NAME=\"examplerust\"\n\
PROJECT_NAME=\"${APP}\"\n\
HTTP_IP=\"${HTTP_IP}\"\n\
HTTP_PORT=${HTTP_PORT}\n\
HTTP_USER=\"${HTTP_USER}\"\n\
HTTP_PASSWORD=\"${HTTP_PASSWORD}\"\n\
ARCHITECTURE=\"x86_64-unknown-linux-musl\"\n\
" > .env
RUN just build
FROM stage2 AS stage3
# ----------------------------------------------------------------
# BUILD STAGE 1
# ----------------------------------------------------------------
FROM stage3 AS stage-build