Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: support build for multi-arch builds #598

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@ jobs:

- stage: deploy
env:
- DESC=shadowbox docker image
- DESC=shadowbox docker image with multi-archs
sudo: required
services: docker
script:
- yarn do shadowbox/docker/build
# https://github.com/ldez/seihon is used to manage multi-arch deployment
- |
curl -sfL https://raw.githubusercontent.com/ldez/seihon/7d38218cc397499330219dd76a39f26e2b545f81/godownloader.sh | bash -s -- -b .
chmod +x seihon
sudo mv seihon /usr/local/bin
- docker run --rm --privileged hypriot/qemu-register
- yarn do shadowbox/server/build
- docker login quay.io -u="$QUAY_IO_USERNAME" -p="$QUAY_IO_PASSWORD"
- docker tag outline/shadowbox quay.io/outline/shadowbox:$TRAVIS_TAG
- docker push quay.io/outline/shadowbox:$TRAVIS_TAG
- docker tag outline/shadowbox quay.io/outline/shadowbox:daily
- docker push quay.io/outline/shadowbox:daily
# skipping arm.v7 because the base docker image(node:8.15.0-alpine) doesn't have a arm.v7 manifest included,
# sh -c 'DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect node:8.15.0-alpine'
- seihon publish -v "${TRAVIS_TAG}" -v "daily" -i quay.io/outline/shadowbox --dry-run=false --template src/shadowbox/docker/tmpl.Dockerfile -b node:8.15.0-alpine --targets=arm.v6,arm.v8,amd64,386

- stage: deploy
env:
Expand Down
92 changes: 92 additions & 0 deletions src/shadowbox/docker/tmpl.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2018 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Versions can be found at https://github.com/Jigsaw-Code/outline-ss-server/releases
ARG SS_VERSION=1.1.0

FROM golang:alpine AS ss_builder
# add git so we can build outline-ss-server from source
RUN apk add --update git && rm -rf /var/cache/apk/*
WORKDIR /tmp
ARG SS_VERSION
RUN git clone --branch "v${SS_VERSION}" https://github.com/Jigsaw-Code/outline-ss-server --single-branch
WORKDIR /tmp/outline-ss-server
ENV GO111MODULE=on
ENV GOOS={{ .GoOS }}
ENV GOARCH={{ .GoARCH }}
ENV GOARM={{ .GoARM }}
ENV CGO_ENABLED=0
RUN go build -o /app/outline-ss-server

FROM golang:alpine AS prombuilder
# Versions can be found at https://github.com/prometheus/prometheus/releases
ARG PM_VERSION=2.4.3
# add git so we can build the prometheus version from source
RUN apk add --update git && rm -rf /var/cache/apk/*
WORKDIR /tmp
RUN git clone --branch "v${PM_VERSION}" https://github.com/prometheus/prometheus --single-branch
WORKDIR /tmp/prometheus
ENV GO111MODULE=on
ENV GOOS={{ .GoOS }}
ENV GOARCH={{ .GoARCH }}
ENV GOARM={{ .GoARM }}
RUN go mod init
RUN go mod vendor
RUN go build -o /app/prometheus ./cmd/prometheus


# See versions at https://hub.docker.com/_/node/
FROM {{ .RuntimeImage }}

# Versions can be found at https://github.com/Jigsaw-Code/outline-ss-server/releases
ARG SS_VERSION

# Save metadata on the software versions we are using.
LABEL shadowbox.node_version=8.15.0
LABEL shadowbox.outline-ss-server_version="${SS_VERSION}"

ARG GITHUB_RELEASE
LABEL shadowbox.github.release="${GITHUB_RELEASE}"

# We use curl to detect the server's public IP. We need to use the --date option in `date` to
# safely grab the ip-to-country database.
RUN apk add --no-cache --upgrade coreutils curl

COPY src/shadowbox/scripts scripts/
COPY src/shadowbox/scripts/update_mmdb.sh /etc/periodic/weekly/update_mmdb

RUN /etc/periodic/weekly/update_mmdb

WORKDIR /root/shadowbox

RUN mkdir bin

COPY --from=ss_builder /app/outline-ss-server ./bin/
COPY --from=prombuilder /app/prometheus ./bin/

COPY src/shadowbox/package.json .
COPY yarn.lock .
# TODO: Replace with plain old "yarn" once the base image is fixed:
# https://github.com/nodejs/docker-node/pull/639
RUN /opt/yarn-v$YARN_VERSION/bin/yarn install --prod

# Install management service
COPY build/shadowbox/app app/

# Create default state directory.
RUN mkdir -p /root/shadowbox/persisted-state

COPY src/shadowbox/docker/cmd.sh /

CMD /cmd.sh