forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
76 lines (61 loc) · 2.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
###
# SimulationCraft docker image
#
# Available build-arg:
# - THREADS=[int] Default 1, provide a value for -j
# - APIKEY=[str] Default '' (empty) SC_DEFAULT_APIKEY used for authentication with blizzard api (armory)
# - PTR_DATA=[int] Default 1, enable the PTR data removing script, to smaller images
##
# Example usage:
# - creating the image (note the dot!)
# docker build --build-arg THREADS=2 --build-arg NONETWORKING=1 -t simulationcraft .
# ^ your intended thread count to optimize simc for
# ^ name of the image
# - run the image
# docker run simulationcraft ./simc spell_query=spell.name=frost_shock
# ^ start of the command
#
# To reduce the footprint of this image all SimulationCraft files are
# removed except for the following files and directories (including
# their files)
# - ./simc
# - ./profiles/*
#
# base image
FROM alpine:latest AS build
ARG THREADS=1
ARG APIKEY=''
ARG PTR_DATA=1
COPY . /app/SimulationCraft/
# install Dependencies
RUN apk --no-cache add --virtual build_dependencies \
compiler-rt-static \
curl-dev \
clang-dev \
llvm \
g++ \
make \
git
# Build
RUN clang++ -v && make -C /app/SimulationCraft/engine release CXX=clang++ -j $THREADS THIN_LTO=1 LLVM_PGO_GENERATE=1 OPTS+="-Os -mtune=generic" SC_DEFAULT_APIKEY={$APIKEY}
# Collect profile guided instrumentation data
RUN cd /app/SimulationCraft/engine && LLVM_PROFILE_FILE="code-%p.profraw" ./simc T26_Raid.simc single_actor_batch=1 iterations=100
# Merge profile guided data
RUN cd /app/SimulationCraft/engine && llvm-profdata merge -output=code.profdata code-*.profraw
# Clean & rebuild with collected profile guided data.
RUN make -C /app/SimulationCraft/engine clean && make -C /app/SimulationCraft/engine release CXX=clang++ -j $THREADS THIN_LTO=1 LLVM_PGO_USE=./code.profdata OPTS+="-Os -mtune=generic" SC_DEFAULT_APIKEY={$APIKEY}
# Cleanup dependencies
RUN apk del build_dependencies
# disable ptr to reduce build size
# if PTR_DATA is equal to 1, it leaves the files in the build.
RUN sh -c "if [ $PTR_DATA -ne 1 ]; then sed -i '' -e 's/#define SC_USE_PTR 1/#define SC_USE_PTR 0/g' engine/dbc.hpp; fi;"
# fresh image to reduce size
FROM alpine:latest
RUN apk --no-cache add --virtual build_dependencies \
libcurl \
libgcc \
libstdc++
# get compiled simc and profiles
COPY --from=build /app/SimulationCraft/engine/simc /app/SimulationCraft/
COPY --from=build /app/SimulationCraft/profiles/ /app/SimulationCraft/profiles/
WORKDIR /app/SimulationCraft