forked from PocketRelay/Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (50 loc) · 1.62 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (50 loc) · 1.62 KB
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
### Build step ###
##################
FROM rust:1.65.0 AS builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
WORKDIR /pocket-relay
# Dependency Caching Build
# Copy cargo project files
COPY ./Cargo.toml .
COPY ./Cargo.lock .
COPY ./database/Cargo.toml ./database/Cargo.toml
COPY ./database/Cargo.lock ./database/Cargo.lock
# Create dummy contents for main source & for migration lib
RUN mkdir ./src && echo 'fn main() { println!("Dummy!"); }' > ./src/main.rs
RUN mkdir ./database/src && touch ./database/src/lib.rs
# Cargo build the dummy project for dependency caching
RUN cargo build --target x86_64-unknown-linux-musl --release
# Remove dummy src
RUN rm -rf ./src
RUN rm -rf ./database/src
# Copy real source code over
COPY ./src ./src
COPY ./database/src ./database/src
# Update the modified time on the project files so they recompile
RUN touch -a -m ./src/main.rs
RUN touch -a -m ./database/src/lib.rs
# Cargo build real source code
RUN cargo build --target x86_64-unknown-linux-musl --release
### Run step ###
################
FROM alpine
WORKDIR /app
# Copy our build
COPY --from=builder /pocket-relay/target/x86_64-unknown-linux-musl/release/pocket-relay ./
# Environment variable configuration
ENV PR_EXT_HOST=gosredirector.ea.com
# Ports
ENV PR_REDIRECTOR_PORT=42127
ENV PR_MAIN_PORT=14219
ENV PR_HTTP_PORT=80
ENV PR_LOG_LEVEL=info
ENV PR_DATABASE_FILE=data/app.db
# Volume for storing database file data
VOLUME /app/data
# Expore main and http ports
EXPOSE $PR_REDIRECTOR_PORT
EXPOSE $PR_MAIN_PORT
EXPOSE $PR_HTTP_PORT
CMD ["/app/pocket-relay"]