forked from flutter/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
117 lines (84 loc) · 2.91 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
FROM ruby:3.3-slim-bookworm@sha256:8c46844152e5c70e7a0f637950a32075e2a145ce6bb418a06d1cd53c946a0161 as base
ENV TZ=US/Pacific
RUN apt-get update && apt-get install -yq --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
diffutils \
git \
gnupg \
lsof \
make \
rsync \
unzip \
xdg-user-dirs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# ============== INSTALL FLUTTER ==============
FROM base AS flutter
COPY ./site-shared ./site-shared
COPY pubspec.yaml ./
ARG FLUTTER_BUILD_BRANCH=stable
ENV FLUTTER_BUILD_BRANCH=$FLUTTER_BUILD_BRANCH
ENV FLUTTER_ROOT=flutter
ENV FLUTTER_BIN=flutter/bin
ENV PATH="/flutter/bin:$PATH"
RUN git clone --branch $FLUTTER_BUILD_BRANCH --single-branch --filter=tree:0 https://github.com/flutter/flutter /flutter/
VOLUME /flutter
# Set up Flutter
# NOTE You will get a warning "Woah! You appear to be trying to run flutter as root."
# and this is to be disregarded since this image is never deployed to production.
RUN flutter doctor
RUN flutter config --no-analytics \
&& flutter config --no-cli-animations \
&& flutter --version
RUN dart pub get
# ============== NODEJS INTSALL ==============
FROM flutter 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
# ============== FLUTTER CODE TESTS ==============
FROM flutter AS tests
COPY ./ ./
# Only test the code here, checking links is purely for site deployment
ENTRYPOINT ["tool/test.sh"]
# ============== DEV / JEKYLL SETUP ==============
FROM node AS dev
ENV JEKYLL_ENV=development
ENV RUBY_YJIT_ENABLE=1
RUN gem install bundler
COPY Gemfile Gemfile.lock ./
RUN bundle config set force_ruby_platform true
RUN bundle install
# Install Node deps
ENV NODE_ENV=development
COPY package.json package-lock.json ./
RUN npm install
COPY ./ ./
# Jekyl ports
EXPOSE 35730
EXPOSE 4002
# Firebase emulator port
# Airplay runs on :5000 by default now
EXPOSE 5502
# ============== BUILD PROD JEKYLL SITE ==============
FROM node AS build
ENV JEKYLL_ENV=production
ENV RUBY_YJIT_ENABLE=1
RUN gem install bundler
COPY Gemfile Gemfile.lock ./
RUN bundle config set force_ruby_platform true
RUN BUNDLE_WITHOUT="test development" bundle install --jobs=4 --retry=2
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN npm ci
COPY ./ ./
RUN echo 'User-agent: *\nDisallow:\n\nSitemap: https://docs.flutter.dev/sitemap.xml' > src/robots.txt
ARG BUILD_CONFIGS=_config.yml
ENV BUILD_CONFIGS=$BUILD_CONFIGS
RUN bundle exec jekyll build --config $BUILD_CONFIGS