diff --git a/.travis.yml b/.travis.yml index 788f901f2..35360612d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,9 @@ matrix: - sudo mv docker-compose /usr/local/bin before_deploy: - python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);' - - docker-compose build package - - docker-compose run package + - docker-compose build + - docker-compose run package14 + - docker-compose run package16 - os: osx env: - CSC_LINK=$MAC_CSC_LINK diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f45b31d26..000000000 --- a/Dockerfile +++ /dev/null @@ -1,77 +0,0 @@ -FROM ubuntu:16.04 - -# Install core deps -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y \ - build-essential \ - autoconf \ - libtool \ - pkg-config \ - snapcraft \ - wget - -# Install Node and app-related dependencies -RUN wget -O- https://deb.nodesource.com/setup_10.x | bash - \ - && apt-get install -y nodejs graphicsmagick icnsutils - -# Build zlib from source (for Curl) -RUN wget -q https://github.com/madler/zlib/archive/v1.2.11.tar.gz -O ./zlib.tar.gz \ - && mkdir -p /src/zlib /build/zlib \ - && tar -xvf zlib.tar.gz -C /src/zlib --strip 1 \ - && cd /src/zlib \ - && ./configure --prefix=/build/zlib \ - && make \ - && make install \ - && ldconfig - -# Build OpenSSL from source (for Curl) -RUN wget -q https://github.com/openssl/openssl/archive/OpenSSL_1_1_0h.tar.gz -O ./openssl.tar.gz \ - && mkdir -p /src/openssl /build/openssl \ - && tar -xvf openssl.tar.gz -C /src/openssl --strip 1 \ - && cd /src/openssl \ - && ./config no-shared --static --prefix=/build/openssl --openssldir=/build/openssl \ - && make \ - && make install \ - && ldconfig - -# Build nghttp2 from source (for Curl) -RUN wget -q https://github.com/nghttp2/nghttp2/releases/download/v1.31.1/nghttp2-1.31.1.tar.gz -O ./nghttp2.tar.gz \ - && mkdir -p /src/nghttp2 /build/nghttp2 \ - && tar -xvf nghttp2.tar.gz -C /src/nghttp2 --strip 1 \ - && cd /src/nghttp2 \ - && CFLAGS="-fPIC" ./configure --enable-lib-only --disable-shared --prefix=/build/nghttp2 \ - && make \ - && make install \ - && ldconfig - -# Build Curl from source -RUN wget -q https://github.com/curl/curl/releases/download/curl-7_61_1/curl-7.61.1.tar.gz -O ./curl.tar.gz \ - && mkdir -p /src/curl \ - && tar -xvf curl.tar.gz -C /src/curl --strip 1 \ - && cd /src/curl \ - && ./buildconf \ - && LIBS="-ldl" CPPFLAGS="-I/build/openssl/include" LDFLAGS="-L/build/openssl/lib" \ - ./configure \ - --disable-shared \ - --enable-static \ - --with-ssl=/build/openssl \ - --with-nghttp2=/build/nghttp2 \ - --with-zlib=/build/zlib \ - --enable-ipv6 \ - --enable-unix-sockets \ - && make \ - && make install \ - && ldconfig \ - && curl --version - -# Setup dirs -ADD . /src/insomnia -WORKDIR /src/insomnia -VOLUME /src/insomnia/packages/insomnia-app/dist - -# Install root project dependencies -RUN npm run bootstrap \ - && npm install --no-save 7zip-bin-linux app-builder-bin-linux - -# Define build command -CMD npm run app-package diff --git a/docker-compose.yaml b/docker-compose.yaml index 50a46c0d3..e5e63dc6e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,8 +1,22 @@ version: '3' services: - package: - build: . - environment: - - 'NODELIBCURL_BUILD_STATIC=yes' + package_linux: + build: + context: '.' + dockerfile: './docker/Dockerfile.Ubuntu14' + environment: + - 'NODELIBCURL_BUILD_STATIC=yes' + - 'BUILD_TARGETS=AppImage,deb,tar.gz' + - 'KEEP_DIST_FOLDER=yes' volumes: - - ./packages/insomnia-app/dist:/src/insomnia/packages/insomnia-app/dist + - ./packages/insomnia-app/dist:/src/insomnia/packages/insomnia-app/dist + package_snap: + build: + context: '.' + dockerfile: './docker/Dockerfile.Ubuntu16' + environment: + - 'NODELIBCURL_BUILD_STATIC=yes' + - 'BUILD_TARGETS=snap' + - 'KEEP_DIST_FOLDER=yes' + volumes: + - ./packages/insomnia-app/dist:/src/insomnia/packages/insomnia-app/dist diff --git a/docker/Dockerfile.Ubuntu14 b/docker/Dockerfile.Ubuntu14 new file mode 100644 index 000000000..388c32b5a --- /dev/null +++ b/docker/Dockerfile.Ubuntu14 @@ -0,0 +1,15 @@ +FROM ubuntu:14.04 + +ADD docker/install-dependencies.sh /scripts/install-dependencies.sh +RUN /scripts/install-dependencies.sh + +# Setup dirs +ADD . /src/insomnia +WORKDIR /src/insomnia +VOLUME /src/insomnia/packages/insomnia-app/dist + +ADD docker/bootstrap.sh /scripts/bootstrap.sh +RUN /scripts/bootstrap.sh + +# Define build command +CMD npm run app-package diff --git a/docker/Dockerfile.Ubuntu16 b/docker/Dockerfile.Ubuntu16 new file mode 100644 index 000000000..4f68e4ec0 --- /dev/null +++ b/docker/Dockerfile.Ubuntu16 @@ -0,0 +1,15 @@ +FROM ubuntu:16.04 + +ADD docker/install-dependencies.sh /scripts/install-dependencies.sh +RUN /scripts/install-dependencies.sh && apt-get install -y snapcraft + +# Setup dirs +ADD . /src/insomnia +WORKDIR /src/insomnia +VOLUME /src/insomnia/packages/insomnia-app/dist + +ADD docker/bootstrap.sh /scripts/bootstrap.sh +RUN /scripts/bootstrap.sh + +# Define build command +CMD npm run app-package diff --git a/docker/bootstrap.sh b/docker/bootstrap.sh new file mode 100755 index 000000000..a4531e7b2 --- /dev/null +++ b/docker/bootstrap.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Fail on any errors +set -e + +# Install root project dependencies +npm run bootstrap +npm install --no-save 7zip-bin-linux app-builder-bin-linux + diff --git a/docker/install-dependencies.sh b/docker/install-dependencies.sh new file mode 100755 index 000000000..30a0ab0f0 --- /dev/null +++ b/docker/install-dependencies.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Fail on any errors +set -e + +# Install core deps +apt-get update +apt-get upgrade -y +apt-get install -y \ + build-essential \ + autoconf \ + libtool \ + pkg-config \ + libfontconfig1-dev \ + wget + +# Install Node and app-related dependencies +wget -O- https://deb.nodesource.com/setup_10.x | bash - +apt-get install -y nodejs graphicsmagick icnsutils + +# Build zlib from source (for Curl) +wget -q https://github.com/madler/zlib/archive/v1.2.11.tar.gz -O ./zlib.tar.gz +mkdir -p /src/zlib /build/zlib +tar -xvf zlib.tar.gz -C /src/zlib --strip 1 +cd /src/zlib +./configure --prefix=/build/zlib +make +make install +ldconfig + +# Build OpenSSL from source (for Curl) +wget -q https://github.com/openssl/openssl/archive/OpenSSL_1_1_0h.tar.gz -O ./openssl.tar.gz +mkdir -p /src/openssl /build/openssl +tar -xvf openssl.tar.gz -C /src/openssl --strip 1 +cd /src/openssl +./config no-shared --static --prefix=/build/openssl --openssldir=/build/openssl +make +make install +ldconfig + +# Build nghttp2 from source (for Curl) +wget -q https://github.com/nghttp2/nghttp2/releases/download/v1.31.1/nghttp2-1.31.1.tar.gz -O ./nghttp2.tar.gz +mkdir -p /src/nghttp2 /build/nghttp2 +tar -xvf nghttp2.tar.gz -C /src/nghttp2 --strip 1 +cd /src/nghttp2 +CFLAGS="-fPIC" ./configure --enable-lib-only --disable-shared --prefix=/build/nghttp2 +make +make install +ldconfig + +# Build Curl from source +wget -q https://github.com/curl/curl/releases/download/curl-7_61_1/curl-7.61.1.tar.gz -O ./curl.tar.gz +mkdir -p /src/curl +tar -xvf curl.tar.gz -C /src/curl --strip 1 +cd /src/curl +./buildconf +LIBS="-ldl" CPPFLAGS="-I/build/openssl/include" LDFLAGS="-L/build/openssl/lib" \ + ./configure \ + --disable-shared \ + --enable-static \ + --with-ssl=/build/openssl \ + --with-nghttp2=/build/nghttp2 \ + --with-zlib=/build/zlib \ + --enable-ipv6 \ + --enable-unix-sockets +make +make install +ldconfig +curl --version diff --git a/packages/insomnia-app/scripts/package.js b/packages/insomnia-app/scripts/package.js index 15da1b70d..4651203b2 100644 --- a/packages/insomnia-app/scripts/package.js +++ b/packages/insomnia-app/scripts/package.js @@ -25,7 +25,10 @@ if (require.main === module) { module.exports.start = async function() { console.log('[package] Removing existing directories'); - await emptyDir('../dist/*'); + + if (process.env.KEEP_DIST_FOLDER !== 'yes') { + await emptyDir('../dist/*'); + } console.log('[package] Packaging app'); await pkg('../.electronbuilder'); @@ -37,9 +40,14 @@ async function pkg(relConfigPath) { const configPath = path.resolve(__dirname, relConfigPath); const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); const targetPlatform = PLATFORM_MAP[process.platform]; + + const target = process.env.BUILD_TARGETS + ? process.env.BUILD_TARGETS.split(',') + : config[targetPlatform].target; + return electronBuilder.build({ config, - [targetPlatform]: config[targetPlatform].target + [targetPlatform]: target }); }