-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathDockerfile
More file actions
161 lines (131 loc) · 5.11 KB
/
Dockerfile
File metadata and controls
161 lines (131 loc) · 5.11 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# ------------------------------------ #
# Odin (Rust) build and runtime stages #
# ------------------------------------ #
ARG DEBIAN_VERSION=12
ARG RUST_VERSION=1.95
ARG UBUNTU_VERSION=24
ARG EXPECTED_OCTAL=775
FROM rust:${RUST_VERSION} AS odin-base
ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
apt-get update && \
apt-get install -y --no-install-recommends cmake && \
rm -rf /var/lib/apt/lists/*
FROM odin-base AS odin-chef
RUN cargo install cargo-chef
FROM odin-chef AS odin-planner
WORKDIR /data/odin
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM odin-chef AS odin-cacher
WORKDIR /data/odin
COPY --from=odin-planner /data/odin/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
FROM odin-base AS odin-builder
WORKDIR /data/odin
COPY . .
COPY --from=odin-cacher /data/odin/target target
COPY --from=odin-cacher /usr/local/cargo/registry /usr/local/cargo/
RUN make release PROFILE=production
FROM debian:${DEBIAN_VERSION}-slim AS odin
WORKDIR /apps
COPY --from=odin-builder /data/odin/target/release/odin /data/odin/target/release/huginn ./
ENTRYPOINT ["/apps/odin"]
CMD ["--version"]
# --------------------------- #
# Valheim server build image #
# --------------------------- #
# Root setup (installs deps, creates steam user/group, etc.)
FROM steamcmd/steamcmd:ubuntu-${UBUNTU_VERSION} AS valheim-root
USER root
ENV TZ=America/Los_Angeles \
DEBIAN_FRONTEND=noninteractive \
PUID=111 \
PGID=1000
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=bind,source=src/scripts/build/setup-system.sh,target=/tmp/setup-system.sh \
bash /tmp/setup-system.sh
# Container information
ARG GITHUB_SHA="not-set"
ARG GITHUB_REF="not-set"
ARG GITHUB_REPOSITORY="not-set"
# Pull Odin binaries from odin-runtime stage
COPY --from=odin --chmod=755 /apps/odin /apps/huginn /usr/local/bin/
# Set version information and configure sudoers
RUN printf "${GITHUB_SHA}\n${GITHUB_REF}\n${GITHUB_REPOSITORY}\n" >/home/steam/.version && \
echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
echo "steam ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# SteamCMD setup
FROM valheim-root AS valheim-steamcmd
USER steam
ENV HOME=/home/steam
ENV USER=steam
ARG EXPECTED_OCTAL
ADD --chown=steam:${PGID} https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz /home/steam/steamcmd.tar.gz
COPY --chmod=${EXPECTED_OCTAL} --chown=steam:${PGID} --from=valheim-root /home/steam/.version /home/steam/.version
RUN --mount=type=bind,source=src/scripts/build/setup-steamcmd.sh,target=/tmp/setup-steamcmd.sh \
bash /tmp/setup-steamcmd.sh
# Final Valheim runtime image
FROM valheim-steamcmd AS valheim
USER steam
ENV HOME=/home/steam
ENV USER=steam
ARG EXPECTED_OCTAL
# Set environment variables for Valheim server
ENV PORT="2456" \
NAME="Valheim Docker" \
WORLD="Dedicated" \
PUBLIC="1" \
TYPE="Vanilla" \
DEBUG_MODE="0" \
ENABLE_CROSSPLAY="0" \
PRESET="" \
MODIFIERS="" \
MODS="" \
UPDATE_ON_STARTUP="1" \
AUTO_UPDATE="0" \
AUTO_UPDATE_SCHEDULE="0 1 * * *" \
AUTO_UPDATE_PAUSE_WITH_PLAYERS="0" \
AUTO_BACKUP="0" \
AUTO_BACKUP_SCHEDULE="*/15 * * * *" \
AUTO_BACKUP_NICE_LEVEL="" \
AUTO_BACKUP_REMOVE_OLD="1" \
AUTO_BACKUP_DAYS_TO_LIVE="3" \
AUTO_BACKUP_ON_UPDATE="0" \
AUTO_BACKUP_ON_SHUTDOWN="0" \
AUTO_BACKUP_PAUSE_WITH_NO_PLAYERS="0" \
SCHEDULED_RESTART="0" \
SCHEDULED_RESTART_SCHEDULE="0 2 * * *" \
SAVE_LOCATION="/home/steam/.config/unity3d/IronGate/Valheim" \
MODS_LOCATION="/home/steam/valheim/BepInEx/plugins" \
GAME_LOCATION="/home/steam/valheim" \
BACKUP_LOCATION="/home/steam/backups" \
WEBHOOK_URL="" \
WEBHOOK_INCLUDE_PUBLIC_IP="0" \
PLAYER_EVENT_NOTIFICATIONS="0" \
WEBHOOK_STATUS_SUCCESSFUL="1" \
WEBHOOK_STATUS_FAILED="1" \
BEPINEX_RELEASES_URL="https://thunderstore.io/api/experimental/package/denikson/BepInExPack_Valheim/" \
WEBHOOK_STATUS_JOINED="1" \
WEBHOOK_STATUS_LEFT="1"
# Copy scripts and set permissions
COPY --chmod=${EXPECTED_OCTAL} --chown=steam:${PGID} ./src/scripts/*.sh /home/steam/scripts/
COPY --chmod=${EXPECTED_OCTAL} --chown=steam:${PGID} ./src/scripts/entrypoint.sh /entrypoint.sh
COPY --chmod=${EXPECTED_OCTAL} --chown=steam:${PGID} ./src/scripts/env.sh /env.sh
COPY --chmod=${EXPECTED_OCTAL} --chown=steam:${PGID} ./src/scripts/steam_bashrc.sh /home/steam/.bashrc
# Convert scripts to Unix format
RUN --mount=type=bind,source=src/scripts/build/valheim-postcopy.sh,target=/tmp/valheim-postcopy.sh \
bash /tmp/valheim-postcopy.sh
# Set the working directory to the game directory
WORKDIR /home/steam/valheim
# Expose the necessary ports
EXPOSE 2456/udp 2457/udp 2458/udp
EXPOSE 2456/tcp 2457/tcp 2458/tcp
EXPOSE 3000/tcp
# Healthcheck to ensure the Valheim server is running
HEALTHCHECK --interval=1m --timeout=3s CMD pidof valheim_server.x86_64 || exit 1
# Define the entrypoint and command
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD ["/bin/bash", "/home/steam/scripts/start_valheim.sh"]