forked from flutter/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
116 lines (92 loc) · 2.73 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
ARG RUBY_VERSION=3
FROM ruby:${RUBY_VERSION}-buster as dev
ENV TZ=US/Pacific
ARG NODE_VERSION=17
ENV NODE_VERSION=$NODE_VERSION
RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x -o node_setup.sh && \
bash node_setup.sh 1> /dev/null
RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
vim \
git \
diffutils \
xdg-user-dirs \
nodejs && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Ruby deps
ENV JEKYLL_ENV=development
RUN gem install bundler
COPY Gemfile Gemfile.lock ./
RUN bundle install
# Install Node deps
ENV NODE_ENV=development
COPY package.json package-lock.json ./
RUN npm install -g npm firebase-tools superstatic
RUN npm install
RUN npm i re2
COPY ./ ./
# So that we have the most up to date submodules
RUN git submodule update --init --recursive
ARG FLUTTER_BRANCH
ENV FLUTTER_BRANCH=$FLUTTER_BRANCH
ENV FLUTTER_ROOT=flutter
ENV FLUTTER_BIN=flutter/bin
ENV PATH="/app/flutter/bin:$PATH"
# Used if wanting to build the container with a different branch
# e.g. `make FLUTTER_BRANCH=dev build`
# This is not to be confused with the $TEST_TARGET_CHANNEL
RUN if test -n "$FLUTTER_BRANCH" -a "$FLUTTER_BRANCH" != "stable" ; then \
cd flutter && \
git fetch && \
git remote set-branches origin "$FLUTTER_BRANCH" && \
git fetch --depth 1 origin "$FLUTTER_BRANCH" && \
git checkout "$FLUTTER_BRANCH" -- && \
git pull; \
fi
# Set up Flutter
RUN flutter doctor
RUN flutter --version
RUN dart pub get
EXPOSE 35729
EXPOSE 4002
# -- Test target
FROM dev as test
ARG DISABLE_TESTS
ENV DISABLE_TESTS=$DISABLE_TESTS
ARG TEST_TARGET_CHANNEL=stable
ENV TEST_TARGET_CHANNEL=$TEST_TARGET_CHANNEL
RUN tool/test.sh --target $TEST_TARGET_CHANNEL --check-links --null-safety
# -- Build target
FROM test AS builder
ENV JEKYLL_ENV=production
ENV NODE_ENV=production
RUN bundle install
RUN npm install
RUN cd flutter && \
git fetch && \
git remote set-branches origin stable && \
git fetch origin stable && \
git checkout stable && \
git pull
RUN flutter doctor
RUN echo "User-agent: *" > src/robots.txt && echo "Allow: /" >> src/robots.txt
ARG BUILD_CONFIGS=_config.yml
ENV BUILD_CONFIGS=$BUILD_CONFIGS
RUN bundle exec jekyll build --config $BUILD_CONFIGS
# -- Deploy target
FROM builder AS deploy
ARG FIREBASE_TOKEN
ENV FIREBASE_TOKEN=$FIREBASE_TOKEN
ARG FIREBASE_ALIAS=default
ENV FIREBASE_ALIAS=${FIREBASE_ALIAS:-default}
ARG BUILD_COMMIT=$(git rev-parse --short HEAD)
ENV BUILD_COMMIT=$COMMIT
RUN firebase use $FIREBASE_ALIAS
RUN firebase deploy -m $BUILD_COMMIT \
--only hosting \
--non-interactive \
--token $FIREBASE_TOKEN \
--project $FIREBASE_ALIAS \
--debug \
--json