Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor build process to not use pre-built bins
This means that there's now a canonical script that allows other distributers to build Browsh. The only caveat being that the web extension cannot be built (Mozilla only allows one signed `.xpi` per version), so it is downloaded.
- Loading branch information
Showing
12 changed files
with
129 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ webextension.go | |
webext/node_modules | ||
webext/dist/* | ||
dist | ||
*.xpi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,87 @@ | ||
FROM bitnami/minideb:stretch as build | ||
|
||
RUN install_packages \ | ||
curl \ | ||
ca-certificates \ | ||
git \ | ||
autoconf \ | ||
automake \ | ||
g++ \ | ||
protobuf-compiler \ | ||
zlib1g-dev \ | ||
libncurses5-dev \ | ||
libssl-dev \ | ||
pkg-config \ | ||
libprotobuf-dev \ | ||
make | ||
|
||
# Install Golang | ||
ENV GOROOT=/go | ||
ENV GOPATH=/go-home | ||
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH | ||
RUN curl -L -o go.tar.gz https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz | ||
RUN mkdir -p $GOPATH/bin | ||
RUN tar -C / -xzf go.tar.gz | ||
|
||
ENV BASE=$GOPATH/src/browsh/interfacer | ||
WORKDIR $BASE | ||
ADD interfacer $BASE | ||
|
||
# Install `dep` the current defacto dependency manager for Golang | ||
RUN $BASE/contrib/setup_dep.sh | ||
|
||
# Install the tool to convert the web extenstion file into a Go-compatible binary | ||
RUN go get -u gopkg.in/shuLhan/go-bindata.v3/... | ||
|
||
# Build Browsh | ||
RUN dep ensure | ||
RUN $BASE/contrib/build_browsh.sh | ||
|
||
|
||
########################### | ||
# Actual final Docker image | ||
########################### | ||
FROM bitnami/minideb:stretch | ||
|
||
RUN install_packages xvfb libgtk-3-0 curl ca-certificates bzip2 libdbus-glib-1-2 procps | ||
ENV HOME=/app | ||
WORKDIR /app | ||
|
||
COPY --from=build /go-home/src/browsh/interfacer/browsh /app/browsh | ||
|
||
RUN install_packages \ | ||
xvfb \ | ||
libgtk-3-0 \ | ||
curl \ | ||
ca-certificates \ | ||
bzip2 \ | ||
libdbus-glib-1-2 \ | ||
procps | ||
|
||
# Block ads, etc. This includes porn just because this image is also used on the | ||
# public SSH demo: `ssh brow.sh`. | ||
RUN curl -o /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts | ||
|
||
# Don't use root | ||
RUN useradd -m user --home /app | ||
RUN chown user:user /app | ||
USER user | ||
ENV HOME=/app | ||
WORKDIR /app | ||
|
||
# These are needed to detect versions | ||
ADD .travis.yml . | ||
ADD ./webext/manifest.json . | ||
|
||
# Setup Firefox | ||
ENV PATH="/app/bin/firefox:${PATH}" | ||
ADD ./interfacer/contrib/setup_firefox.sh . | ||
ENV PATH="${HOME}/bin/firefox:${PATH}" | ||
ADD .travis.yml . | ||
ADD interfacer/contrib/setup_firefox.sh . | ||
RUN ./setup_firefox.sh | ||
RUN rm ./setup_firefox.sh && rm .travis.yml | ||
|
||
# Setup Browsh | ||
ADD ./interfacer/contrib/setup_browsh.sh . | ||
ADD ./interfacer/src/browsh/version.go . | ||
RUN VERSION_FILE=version.go ./setup_browsh.sh | ||
RUN rm ./setup_browsh.sh && rm version.go | ||
RUN rm setup_firefox.sh && rm .travis.yml | ||
|
||
# Firefox behaves quite differently to normal on its first run, so by getting | ||
# that over and done with here when there's no user to be dissapointed means | ||
# that all future runs will be consistent. | ||
RUN TERM=xterm script \ | ||
--return \ | ||
-c "/app/browsh" \ | ||
/dev/null \ | ||
>/dev/null & \ | ||
sleep 10 | ||
--return \ | ||
-c "/app/browsh" \ | ||
/dev/null \ | ||
>/dev/null & \ | ||
sleep 10 | ||
|
||
CMD ["/app/browsh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# This is for building a production version of Browsh. | ||
# To build Browsh during development see: | ||
# https://github.com/browsh-org/browsh#contributing | ||
|
||
# This script depends on Golang and go-bindata | ||
# `go get -u gopkg.in/shuLhan/go-bindata.v3/...` | ||
|
||
set -e | ||
|
||
INTERFACER_ROOT=$(readlink -m "$( cd "$(dirname "$0")" ; pwd -P )"/../) | ||
|
||
version_file=$INTERFACER_ROOT/src/browsh/version.go | ||
line=$(cat $version_file | grep 'browshVersion') | ||
version=$(echo $line | grep -o '".*"' | sed 's/"//g') | ||
|
||
base='https://github.com/browsh-org/browsh/releases/download' | ||
release_url="$base/v$version/browsh-${version}-an.fx.xpi" | ||
|
||
xpi_file=$INTERFACER_ROOT/browsh.xpi | ||
destination=$INTERFACER_ROOT/src/browsh/webextension.go | ||
|
||
curl -L -o $xpi_file $release_url | ||
|
||
XPI_FILE=$xpi_file BIN_FILE=$destination \ | ||
$INTERFACER_ROOT/contrib/xpi2bin.sh | ||
|
||
cd $INTERFACER_ROOT | ||
go build -o browsh src/main.go |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
INTERFACER_ROOT=$(readlink -m "$( cd "$(dirname "$0")" ; pwd -P )"/../) | ||
|
||
go-bindata -version | ||
go-bindata \ | ||
-nocompress \ | ||
-prefix $INTERFACER_ROOT \ | ||
-pkg browsh \ | ||
-o $BIN_FILE \ | ||
$XPI_FILE | ||
|
||
ls -alh $INTERFACER_ROOT/src/browsh/webextension.go | ||
echo "go-bindata exited with $(echo $?)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package browsh | ||
|
||
var browshVersion = "1.4.8" | ||
var browshVersion = "1.4.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters