-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
78 lines (61 loc) · 1.95 KB
/
Containerfile
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
# Building this image's first stage (datagen) expects that the Barotrauma's
# Content directory is bind mounted in at /Content, for example:
#
# podman build -v /games/Barotrauma/Content:/Content:ro
#
# Building the webbuild stage will write static files to /build/web/dist
#
# Building the pagesupload stage
FROM alpine:latest AS datagen
RUN apk update
RUN apk add python3 nodejs npm py3-lxml py3-pillow
# build sprite sheet and item data
WORKDIR /build
ADD baro-data.py .
RUN mkdir -p web/assets
ARG DATAGEN_ARGS="--content /Content"
# goofy hack to properly escape/unescape multi-argument arguments???
RUN echo -n "${DATAGEN_ARGS}" | xargs python3 baro-data.py --output web/assets/bundles/
# install web stuff
FROM datagen AS webinstall
WORKDIR /build/web
ADD web/package.json \
web/package-lock.json \
.
RUN npm install
ADD web/index.html \
web/index.html \
web/tsconfig.json \
web/vite.config.js \
.git-commit-hash \
.
ADD web/src src
ADD web/public public
ADD web/assets assets
CMD npm x -- vite
FROM webinstall AS webbuild
# alternatively, just put the date in vite.config.js defines or something?
# and import .git-commit-hash?raw in javascript? idk
RUN env VITE_BUILD_DATE=$(date -Is) \
VITE_BUILD_HASH=$(cat .git-commit-hash) \
npm x -- vite build
# to upload to cloudflare pages
#
# requires environment variables
# CLOUDFLARE_ACCOUNT_ID
# CLOUDFLARE_API_TOKEN
#
# put them in a file and bind mount into the container when needed
# (example with secrets in password store using fish shell's psub)
#
# podman run --rm \
# -v (pass s/cloudflare/apikeys | psub):/run/secrets/cloudflare \
# however-you-tagged-the-build ash \
# -c 'npm install wrangler \
# && env $(cat /run/secrets/cloudflare) \
# npm x -- wrangler pages deploy --project-name materialist ./dist'
# unused...
#
# FROM scratch AS webdist
#
# COPY --from=webbuild /build/web/dist /webdist