Skip to content

Commit 07c217f

Browse files
author
jld3103
authored
Optimize Dockerfile (#108)
1 parent 74bbb5f commit 07c217f

File tree

1 file changed

+46
-56
lines changed

1 file changed

+46
-56
lines changed

Dockerfile

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,84 @@
11
FROM snapcore/snapcraft AS snapcraft
22
# Using multi-stage dockerfile to obtain snapcraft binary
33

4+
FROM ubuntu:bionic AS flutterbuilder
5+
RUN apt-get update \
6+
&& apt-get install -y \
7+
git curl unzip
8+
# Install Flutter from the beta channel
9+
RUN git clone --single-branch --depth=1 --branch beta https://github.com/flutter/flutter /opt/flutter 2>&1 \
10+
&& /opt/flutter/bin/flutter doctor -v
11+
412
FROM ubuntu:bionic AS xarbuilder
513
RUN apt-get update \
614
&& apt-get install -y \
7-
wget tar libssl1.0-dev libxml2-dev make g++
8-
RUN cd /tmp \
9-
&& wget https://github.com/downloads/mackyle/xar/xar-1.6.1.tar.gz 2>&1 \
10-
&& tar -zxvf xar-1.6.1.tar.gz 2>&1 \
11-
&& mv xar-1.6.1 xar \
12-
&& cd xar \
15+
git libssl1.0-dev libxml2-dev make g++ autoconf
16+
RUN git clone --single-branch --depth=1 --branch xar-1.6.1 https://github.com/mackyle/xar 2>&1 \
17+
&& cd xar/xar \
18+
&& ./autogen.sh --noconfigure \
1319
&& ./configure 2>&1 \
1420
&& make 2>&1 \
1521
&& make install 2>&1
1622

17-
FROM dockercore/golang-cross:1.13.10 AS hover
23+
FROM ubuntu:bionic AS bomutilsbuilder
24+
RUN apt-get update \
25+
&& apt-get install -y \
26+
git make g++
27+
RUN git clone --single-branch --depth=1 --branch 0.2 https://github.com/hogliux/bomutils 2>&1 \
28+
&& cd bomutils \
29+
&& make 2>&1 \
30+
&& make install 2>&1
1831

19-
# Add dart apt repository
20-
RUN wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 2>&1 \
21-
&& wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list
32+
# Fixed using https://github.com/AppImage/AppImageKit/issues/828
33+
FROM ubuntu:bionic as appimagebuilder
34+
RUN apt-get update \
35+
&& apt-get install -y \
36+
curl
37+
RUN cd /opt \
38+
&& curl -LO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage \
39+
&& chmod a+x appimagetool-x86_64.AppImage \
40+
&& sed 's|AI\x02|\x00\x00\x00|g' -i appimagetool-x86_64.AppImage \
41+
&& ./appimagetool-x86_64.AppImage --appimage-extract \
42+
&& mv squashfs-root appimagetool
43+
44+
FROM dockercore/golang-cross:1.13.10 AS hover
2245

2346
# Install dependencies via apt
2447
RUN apt-get update \
25-
&& apt-get upgrade -y \
2648
&& apt-get install -y \
27-
# why is gnupg-agent needed? Can this be removed??
28-
gnupg-agent \
29-
# for what command are these dependencies??
49+
# dependencies for compiling linux
3050
libgl1-mesa-dev xorg-dev \
31-
# dependencies for flutter
32-
dart unzip \
3351
# dependencies for darwin-bundle
3452
icnsutils \
3553
# dependencies for darwin-dmg
3654
genisoimage \
3755
# dependencies for darwin-pkg
3856
cpio git \
39-
# dependencies for linux-appimage
40-
libglib2.0-0 curl file \
4157
# dependencies for linux-rpm
4258
rpm \
43-
# dependencies for linux-snap
44-
locales \
4559
# dependencies for windows-msi
4660
wixl imagemagick \
47-
&& rm -rf /var/lib/apt/lists/* \
48-
&& ln -sf /usr/lib/dart/bin/pub /usr/bin/pub
61+
&& rm -rf /var/lib/apt/lists/*
62+
63+
COPY --from=snapcraft /snap /snap
64+
ENV PATH="/snap/bin:$PATH"
65+
ENV SNAP="/snap/snapcraft/current"
66+
ENV SNAP_NAME="snapcraft"
67+
ENV SNAP_ARCH="amd64"
4968

50-
# Install darwin-pkg dependencies
51-
# TODO, optimization: make bomutils in a separate stage, copy binaries/libs, like xar.
52-
RUN cd /tmp \
53-
&& git clone https://github.com/hogliux/bomutils 2>&1 \
54-
&& cd bomutils \
55-
&& make 2>&1 \
56-
&& make install 2>&1
5769
COPY --from=xarbuilder /usr/local/bin/xar /usr/local/bin/xar
5870
COPY --from=xarbuilder /usr/local/lib/libxar.so.1 /usr/local/lib/libxar.so.1
5971
COPY --from=xarbuilder /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
6072

61-
# Install linux-appimage dependencies
62-
# Fixed using https://github.com/AppImage/AppImageKit/issues/828
63-
RUN cd /opt \
64-
&& curl -LO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage \
65-
&& chmod a+x appimagetool-x86_64.AppImage \
66-
&& sed 's|AI\x02|\x00\x00\x00|g' -i appimagetool-x86_64.AppImage \
67-
&& ./appimagetool-x86_64.AppImage --appimage-extract \
68-
&& mv squashfs-root appimagetool \
69-
&& rm appimagetool-x86_64.AppImage
70-
ENV PATH=/opt/appimagetool/usr/bin:$PATH
73+
COPY --from=bomutilsbuilder /usr/bin/mkbom /usr/bin/mkbom
7174

72-
# Install linux-snap dependencies (based on https://hub.docker.com/r/snapcore/snapcraft/dockerfile)
73-
COPY --from=snapcraft /snap/core /snap/core
74-
COPY --from=snapcraft /snap/snapcraft /snap/snapcraft
75-
COPY --from=snapcraft /snap/bin/snapcraft /snap/bin/snapcraft
76-
# RUN locale-gen en_US.UTF-8 # TODO: remove locales from apt install above or re-enable these env vars
77-
# ENV LANG="en_US.UTF-8"
78-
# ENV LANGUAGE="en_US:en"
79-
# ENV LC_ALL="en_US.UTF-8"
80-
ENV PATH="/snap/bin:$PATH"
81-
ENV SNAP="/snap/snapcraft/current"
82-
ENV SNAP_NAME="snapcraft"
83-
ENV SNAP_ARCH="amd64"
84-
# RUN dpkg-reconfigure locales
75+
COPY --from=appimagebuilder /opt/appimagetool /opt/appimagetool
76+
ENV PATH=/opt/appimagetool/usr/bin:$PATH
8577

8678
# TODO: Add pacman pkg packaging
8779

88-
# Install Flutter from the beta channel
89-
RUN git clone --single-branch --depth=1 --branch beta https://github.com/flutter/flutter /opt/flutter 2>&1 \
90-
&& ln -sf /opt/flutter/bin/flutter /usr/bin/flutter \
91-
&& flutter doctor -v
80+
COPY --from=flutterbuilder /opt/flutter /opt/flutter
81+
RUN ln -sf /opt/flutter/bin/flutter /usr/bin/flutter
9282

9383
# Build hover
9484
WORKDIR /go/src/app

0 commit comments

Comments
 (0)