forked from dart-lang/site-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
168 lines (135 loc) · 4.82 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
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
162
163
164
165
166
167
168
FROM ruby:3.2-slim-bookworm@sha256:75f884a28c1337d744a42b006d864d3ba161c6b1980d2414910e660d2034b14e as base
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=US/Pacific
RUN apt update && apt install -yq --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
gnupg \
lsof \
make \
unzip \
vim-nox \
&& rm -rf /var/lib/apt/lists/*
RUN echo "alias lla='ls -lAhG --color=auto'" >> ~/.bashrc
WORKDIR /root
# google-chrome-stable
# ============== DART ==============
# See https://github.com/dart-lang/dart-docker
# See https://github.com/dart-lang/setup-dart/blob/main/setup.sh
FROM base as dart
ARG DART_VERSION=latest
ARG DART_CHANNEL=stable
ENV DART_VERSION=$DART_VERSION
ENV DART_CHANNEL=$DART_CHANNEL
ENV DART_SDK=/usr/lib/dart
ENV PATH=$DART_SDK/bin:$PATH
RUN set -eu; \
case "$(dpkg --print-architecture)_${DART_CHANNEL}" in \
# BEGIN dart-sha
amd64_stable) \
DART_SHA256="7604c091455b7c3e4b3f52a5966b07f4accb657954c54257fe84cddfc77379ae"; \
SDK_ARCH="x64";; \
arm64_stable) \
DART_SHA256="5a3084385df7014fea762fbb8cb985364f65a041a1446db6955cdac670cc8038"; \
SDK_ARCH="arm64";; \
amd64_beta) \
DART_SHA256="24fee21a8e378050b0b0611602f674059d5a93bb09a560539857e384f1b83056"; \
SDK_ARCH="x64";; \
arm64_beta) \
DART_SHA256="f86de4ab4f99a2dbdc6a0809acaae40a280fa3cbac340bbdf910cf7f0085dcbb"; \
SDK_ARCH="arm64";; \
amd64_dev) \
DART_SHA256="439b0c5d0774eccffb09ec84405685eb7d1c4ab0f2207ff6b86add0ed7d8c457"; \
SDK_ARCH="x64";; \
arm64_dev) \
DART_SHA256="c711a28fc49319a4a8b0e004c7542266ab13fd2f093344d326b509d014ef6d79"; \
SDK_ARCH="arm64";; \
# END dart-sha
esac; \
SDK="dartsdk-linux-${SDK_ARCH}-release.zip"; \
BASEURL="https://storage.googleapis.com/dart-archive/channels"; \
URL="$BASEURL/$DART_CHANNEL/release/$DART_VERSION/sdk/$SDK"; \
curl -fsSLO "$URL"; \
echo "$DART_SHA256 *$SDK" | sha256sum --check --status --strict - || (\
echo -e "\n\nDART CHECKSUM FAILED! Run 'make fetch-sums' for updated values.\n\n" && \
rm "$SDK" && \
exit 1 \
); \
unzip "$SDK" > /dev/null && mv dart-sdk "$DART_SDK" && rm "$SDK";
ENV PUB_CACHE="${HOME}/.pub-cache"
RUN dart --disable-analytics
RUN echo -e "Successfully installed Dart SDK:" && dart --version
# ============== DART-TESTS ==============
from dart as dart-tests
WORKDIR /app
COPY ./ ./
RUN dart pub get
ENV BASE_DIR=/app
ENV TOOL_DIR=$BASE_DIR/tool
CMD ["./tool/test.sh"]
# ============== NODEJS INSTALL ==============
FROM dart as node
RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update -yq \
&& apt-get install nodejs -yq \
&& npm install -g npm # Ensure latest npm
# ============== DEV/JEKYLL SETUP ==============
FROM node as dev
WORKDIR /app
ENV JEKYLL_ENV=development
COPY Gemfile Gemfile.lock ./
RUN gem update --system && gem install bundler
RUN BUNDLE_WITHOUT="test production" bundle install --jobs=4 --retry=2
ENV NODE_ENV=development
COPY package.json package-lock.json ./
RUN npm install -g firebase-tools@13.0.2
RUN npm install
COPY ./ ./
# Ensure packages are still up-to-date if anything has changed
# RUN dart pub get --offline
RUN dart pub get
# Let's not play "which dir is this"
ENV BASE_DIR=/app
ENV TOOL_DIR=$BASE_DIR/tool
# Jekyl
EXPOSE 4000
EXPOSE 35729
# Firebase emulator port
# Airplay runs on :5000 by default now
EXPOSE 5500
# re-enable defult in case we want to test packages
ENV DEBIAN_FRONTEND=dialog
# ============== FIREBASE EMULATE ==============
FROM dev as emulate
RUN bundle exec jekyll build --config _config.yml,_config_test.yml
CMD ["make", "emulate"]
# ============== BUILD PROD JEKYLL SITE ==============
FROM node AS build
WORKDIR /app
ENV JEKYLL_ENV=production
COPY Gemfile Gemfile.lock ./
RUN gem update --system && gem install bundler
RUN BUNDLE_WITHOUT="test development" bundle install --jobs=4 --retry=2 --quiet
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN npm install
COPY ./ ./
RUN dart pub get
ENV BASE_DIR=/app
ENV TOOL_DIR=$BASE_DIR/tool
ARG BUILD_CONFIGS=_config.yml
ENV BUILD_CONFIGS=$BUILD_CONFIGS
RUN bundle exec jekyll build --config $BUILD_CONFIGS
# ============== DEPLOY to FIREBASE ==============
FROM build as deploy
RUN npm install -g firebase-tools@13.0.2
ARG FIREBASE_TOKEN
ENV FIREBASE_TOKEN=$FIREBASE_TOKEN
ARG FIREBASE_PROJECT=default
ENV FIREBASE_PROJECT=$FIREBASE_PROJECT
RUN [[ -z "$FIREBASE_TOKEN" ]] && echo "FIREBASE_TOKEN is required for container deploy!"
RUN make deploy-ci