forked from cfug/dart.cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
174 lines (142 loc) · 5 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
174
FROM ruby:3-slim-bullseye@sha256:9c8c162169de5f3d4611c255251186fcbceae8c7942ea72993bf5f0e23489016 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="f64fbc5b90c6817d6f3a25cf9cec4277343cf265df233600838050639c593889"; \
SDK_ARCH="x64";; \
arm64_stable) \
DART_SHA256="f8c6d7e1b0f090c536a64a6a130b065533efd83c290f4510f42325389a0c27a5"; \
SDK_ARCH="arm64";; \
amd64_beta) \
DART_SHA256="3de768ca2def7f953f8fe17c5d4e332cd18f3220ecdf28bb331b007edf58551e"; \
SDK_ARCH="x64";; \
arm64_beta) \
DART_SHA256="34ddc9dac6022102c212465dde93dba8cad65a5fe2d8b54646c1a6114e58b48c"; \
SDK_ARCH="arm64";; \
amd64_dev) \
DART_SHA256="1b8c1d58e4b8773be325152b16cc86edaac8b2e885ca7d629486b5e3af97678a"; \
SDK_ARCH="x64";; \
arm64_dev) \
DART_SHA256="7a31c77239860b22c42029f8090f4c7fd4b52924c67406c1bbc26637d477a4f6"; \
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=2a7d087bd1843b760f9c7462dfd687869655cebf42605fdaf8a746892cf4e9d6; \
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
RUN tool/translator/build.sh
# ============== 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