forked from dart-lang/site-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
173 lines (141 loc) · 4.97 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
169
170
171
172
173
FROM ruby:3.2-slim-bullseye@sha256:cae4a499f8ca1d9084dfa7ccfbaa35f3e2d0088368132c0acdf2cff556cc99d4 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 \
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 \
amd64_stable) \
DART_SHA256="f8591944512834ba19b4d8383d270d7f56fef03c56ba53d4e35c23db80ea8a33"; \
SDK_ARCH="x64";; \
arm64_stable) \
DART_SHA256="c81303feea24228148bd4ec14c65bb9c341cba3596e3d68e8a874a9df947f928"; \
SDK_ARCH="arm64";; \
amd64_beta) \
DART_SHA256="ad962441d3f9c5fb2d7717d6589fb2eceb781d38ca1703ce8caa9e2d88296e9b"; \
SDK_ARCH="x64";; \
arm64_beta) \
DART_SHA256="408304dec3abf68af0ec1f1a2f44165c88b95fe661027f2b7ca7dea482513f36"; \
SDK_ARCH="arm64";; \
amd64_dev) \
DART_SHA256="667ccd540931217e27d5f1f522a70009b5c7a1f030f7d68de2370779363ae672"; \
SDK_ARCH="x64";; \
arm64_dev) \
DART_SHA256="3e29693eeb844bd04a83893a350766fa4f11aa4db2e3287fd2828d3c05613703"; \
SDK_ARCH="arm64";; \
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 set -eu; \
NODE_PPA="node_ppa.sh"; \
NODE_SHA256=061519c83ce8799cc00d36e3bab85ffcb9a8b4164c57b536cc2837048de9939f; \
curl -fsSL https://deb.nodesource.com/setup_lts.x -o "$NODE_PPA"; \
echo "$NODE_SHA256 $NODE_PPA" | sha256sum --check --status --strict - || (\
echo -e "\n\nNODE CHECKSUM FAILED! Run tool/fetch-node-ppa-sum.sh for updated values.\n\n" && \
rm "$NODE_PPA" && \
exit 1 \
); \
sh "$NODE_PPA" && rm "$NODE_PPA"; \
apt-get update -q && apt-get install -yq --no-install-recommends \
nodejs \
&& rm -rf /var/lib/apt/lists/*
# Ensure latest NPM
RUN npm install -g 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 [email protected]
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 [email protected]
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