mirror of https://github.com/coder/coder.git
Build enterprise coder binary by default (#3517)
* Build enterprise coder binary by default Signed-off-by: Spike Curtis <spike@coder.com> * Add --agpl to develop.sh Signed-off-by: Spike Curtis <spike@coder.com> * Add --agpl flag to archive.sh Signed-off-by: Spike Curtis <spike@coder.com> * shell format Signed-off-by: Spike Curtis <spike@coder.com> * Move AGPL back to LICENSE, explain enterprise license is forthcoming Signed-off-by: Spike Curtis <spike@coder.com> Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
parent
4be61d9250
commit
5817c6ac7f
|
@ -0,0 +1,9 @@
|
|||
LICENSE (GNU Affero General Public License) applies to
|
||||
all files in this repository, except for those in or under
|
||||
any directory named "enterprise", which are Copyright Coder
|
||||
Technologies, Inc., All Rights Reserved.
|
||||
|
||||
We plan to release an enterprise license covering these files
|
||||
as soon as possible. Watch this space.
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
_ "time/tzdata"
|
||||
|
||||
"github.com/coder/coder/cli"
|
||||
"github.com/coder/coder/cli/cliui"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixMicro())
|
||||
|
||||
cmd, err := cli.Root().ExecuteC()
|
||||
if err != nil {
|
||||
if errors.Is(err, cliui.Canceled) {
|
||||
os.Exit(1)
|
||||
}
|
||||
cobraErr := cli.FormatCobraError(err, cmd)
|
||||
_, _ = fmt.Fprintln(os.Stderr, cobraErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
# This script creates an archive containing the given binary renamed to
|
||||
# `coder(.exe)?`, as well as the README.md and LICENSE files from the repo root.
|
||||
#
|
||||
# Usage: ./archive.sh --format tar.gz [--output path/to/output.tar.gz] [--sign-darwin] path/to/binary
|
||||
# Usage: ./archive.sh --format tar.gz [--output path/to/output.tar.gz] [--sign-darwin] [--agpl] path/to/binary
|
||||
#
|
||||
# The --format parameter must be set, and must either be "zip" or "tar.gz".
|
||||
#
|
||||
|
@ -14,7 +14,9 @@
|
|||
# utility and then notarized using the `gon` utility, which may take a while.
|
||||
# $AC_APPLICATION_IDENTITY must be set and the signing certificate must be
|
||||
# imported for this to work. Also, the input binary must already be signed with
|
||||
# the `codesign` tool.
|
||||
# the `codesign` tool.=
|
||||
#
|
||||
# If the --agpl parameter is specified, only includes AGPL license.
|
||||
#
|
||||
# The absolute output path is printed on success.
|
||||
|
||||
|
@ -25,8 +27,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|||
format=""
|
||||
output_path=""
|
||||
sign_darwin=0
|
||||
agpl="${CODER_BUILD_AGPL:-0}"
|
||||
|
||||
args="$(getopt -o "" -l format:,output:,sign-darwin -- "$@")"
|
||||
args="$(getopt -o "" -l format:,output:,sign-darwin,agpl -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
|
@ -50,6 +53,10 @@ while true; do
|
|||
sign_darwin=1
|
||||
shift
|
||||
;;
|
||||
--agpl)
|
||||
agpl=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -101,7 +108,13 @@ cdroot
|
|||
temp_dir="$(mktemp -d)"
|
||||
ln -s "$input_file" "$temp_dir/$output_file"
|
||||
ln -s "$(realpath README.md)" "$temp_dir/"
|
||||
ln -s "$(realpath LICENSE)" "$temp_dir/"
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
ln -s "$(realpath LICENSE.agpl)" "$temp_dir/LICENSE"
|
||||
else
|
||||
ln -s "$(realpath LICENSE)" "$temp_dir/"
|
||||
ln -s "$(realpath LICENSE.agpl)" "$temp_dir/"
|
||||
ln -s "$(realpath LICENSE.enterprise)" "$temp_dir/"
|
||||
fi
|
||||
|
||||
# Ensure parent output dir and non-existent output file.
|
||||
mkdir -p "$(dirname "$output_path")"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# This script builds a single Go binary of Coder with the given parameters.
|
||||
#
|
||||
# Usage: ./build_go.sh [--version 1.2.3-devel+abcdef] [--os linux] [--arch amd64] [--output path/to/output] [--slim]
|
||||
# Usage: ./build_go.sh [--version 1.2.3-devel+abcdef] [--os linux] [--arch amd64] [--output path/to/output] [--slim] [--agpl]
|
||||
#
|
||||
# Defaults to linux:amd64 with slim disabled, but can be controlled with GOOS,
|
||||
# GOARCH and CODER_SLIM_BUILD=1. If no version is specified, defaults to the
|
||||
|
@ -19,6 +19,9 @@
|
|||
# If the --sign-darwin parameter is specified and the OS is darwin, binaries
|
||||
# will be signed using the `codesign` utility. $AC_APPLICATION_IDENTITY must be
|
||||
# set and the signing certificate must be imported for this to work.
|
||||
#
|
||||
# If the --agpl parameter is specified, builds only the AGPL-licensed code (no
|
||||
# Coder enterprise features).
|
||||
|
||||
set -euo pipefail
|
||||
# shellcheck source=scripts/lib.sh
|
||||
|
@ -31,8 +34,9 @@ arch="${GOARCH:-amd64}"
|
|||
slim="${CODER_SLIM_BUILD:-0}"
|
||||
sign_darwin=0
|
||||
output_path=""
|
||||
agpl="${CODER_BUILD_AGPL:-0}"
|
||||
|
||||
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,sign-darwin -- "$@")"
|
||||
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
|
@ -56,6 +60,10 @@ while true; do
|
|||
slim=1
|
||||
shift
|
||||
;;
|
||||
--agpl)
|
||||
agpl=1
|
||||
shift
|
||||
;;
|
||||
--sign-darwin)
|
||||
if [[ "${AC_APPLICATION_IDENTITY:-}" == "" ]]; then
|
||||
error "AC_APPLICATION_IDENTITY must be set when --sign-darwin is supplied"
|
||||
|
@ -115,9 +123,13 @@ elif [[ "$arch" == "armv"* ]] || [[ "$arch" == "arm64v"* ]]; then
|
|||
arch="${arch//v*/}"
|
||||
fi
|
||||
|
||||
cmd_path="./enterprise/cmd/coder"
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
cmd_path="./cmd/coder"
|
||||
fi
|
||||
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" GOARM="$arm_version" go build \
|
||||
"${build_args[@]}" \
|
||||
./cmd/coder 1>&2
|
||||
"$cmd_path" 1>&2
|
||||
|
||||
if [[ "$sign_darwin" == 1 ]] && [[ "$os" == "darwin" ]]; then
|
||||
codesign -s "$AC_APPLICATION_IDENTITY" -f -v --timestamp --options runtime "$output_path"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# This script builds multiple Go binaries for Coder with the given OS and
|
||||
# architecture combinations.
|
||||
#
|
||||
# Usage: ./build_go_matrix.sh [--version 1.2.3-devel+abcdef] [--output dist/] [--slim] [--sign-darwin] [--archive] [--package-linux] os1:arch1,arch2 os2:arch1 os1:arch3
|
||||
# Usage: ./build_go_matrix.sh [--version 1.2.3-devel+abcdef] [--output dist/] [--slim] [--sign-darwin] [--archive] [--package-linux] [--agpl] os1:arch1,arch2 os2:arch1 os1:arch3
|
||||
#
|
||||
# If no OS:arch combinations are provided, nothing will happen and no error will
|
||||
# be returned. Slim builds are disabled by default. If no version is specified,
|
||||
|
@ -30,6 +30,9 @@
|
|||
#
|
||||
# If the --package-linux parameter is specified, all linux binaries will be
|
||||
# packaged using ./package.sh. Requires the nfpm binary.
|
||||
#
|
||||
# If the --agpl parameter is specified, builds only the AGPL-licensed code (no
|
||||
# Coder enterprise features).
|
||||
|
||||
set -euo pipefail
|
||||
# shellcheck source=scripts/lib.sh
|
||||
|
@ -41,8 +44,9 @@ slim=0
|
|||
sign_darwin=0
|
||||
archive=0
|
||||
package_linux=0
|
||||
agpl=0
|
||||
|
||||
args="$(getopt -o "" -l version:,output:,slim,sign-darwin,archive,package-linux -- "$@")"
|
||||
args="$(getopt -o "" -l version:,output:,slim,sign-darwin,archive,package-linux,agpl -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
|
@ -73,6 +77,10 @@ while true; do
|
|||
package_linux=1
|
||||
shift
|
||||
;;
|
||||
--agpl)
|
||||
agpl=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -167,6 +175,9 @@ fi
|
|||
if [[ "$sign_darwin" == 1 ]]; then
|
||||
build_args+=(--sign-darwin)
|
||||
fi
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
build_args+=(--agpl)
|
||||
fi
|
||||
|
||||
# Build each spec.
|
||||
for spec in "${specs[@]}"; do
|
||||
|
@ -208,6 +219,9 @@ for spec in "${specs[@]}"; do
|
|||
if [[ "$sign_darwin" == 1 ]] && [[ "$spec_os" == "darwin" ]]; then
|
||||
archive_args+=(--sign-darwin)
|
||||
fi
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
archive_args+=(--agpl)
|
||||
fi
|
||||
|
||||
log "--- Creating archive for $spec_os $spec_arch ($spec_output_archive)"
|
||||
execrelative ./archive.sh \
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# This script builds multiple "slim" Go binaries for Coder with the given OS and
|
||||
# architecture combinations. This wraps ./build_go_matrix.sh.
|
||||
#
|
||||
# Usage: ./build_go_slim.sh [--version 1.2.3-devel+abcdef] [--output dist/] [--compress 22] os1:arch1,arch2 os2:arch1 os1:arch3
|
||||
# Usage: ./build_go_slim.sh [--version 1.2.3-devel+abcdef] [--output dist/] [--compress 22] [--agpl] os1:arch1,arch2 os2:arch1 os1:arch3
|
||||
#
|
||||
# If no OS:arch combinations are provided, nothing will happen and no error will
|
||||
# be returned. If no version is specified, defaults to the version from
|
||||
|
@ -19,6 +19,9 @@
|
|||
# When the --compress <level> parameter is provided, the binaries in site/bin
|
||||
# will be compressed using zstd into site/bin/coder.tar.zst, this helps reduce
|
||||
# final binary size significantly.
|
||||
#
|
||||
# If the --agpl parameter is specified, builds only the AGPL-licensed code (no
|
||||
# Coder enterprise features).
|
||||
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
|
@ -28,8 +31,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|||
version=""
|
||||
output_path=""
|
||||
compress=0
|
||||
agpl=0
|
||||
|
||||
args="$(getopt -o "" -l version:,output:,compress: -- "$@")"
|
||||
args="$(getopt -o "" -l version:,output:,compress:,agpl -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
|
@ -45,6 +49,10 @@ while true; do
|
|||
compress="$2"
|
||||
shift 2
|
||||
;;
|
||||
--agpl)
|
||||
agpl=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -85,10 +93,15 @@ else
|
|||
output_path="$(realpath "${output_path}coder-slim_{version}_{os}_{arch}")"
|
||||
fi
|
||||
|
||||
build_args=(--slim)
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
build_args+=(--agpl)
|
||||
fi
|
||||
|
||||
./scripts/build_go_matrix.sh \
|
||||
--version "$version" \
|
||||
--output "$output_path" \
|
||||
--slim \
|
||||
"${build_args[@]}" \
|
||||
"$@"
|
||||
|
||||
cdroot
|
||||
|
|
|
@ -17,7 +17,7 @@ fi
|
|||
|
||||
if [[ ! -x "${CODER_DEV_BIN}" ]]; then
|
||||
echo "Run this command first:"
|
||||
echo "go build -o ${CODER_DEV_BIN} ${PROJECT_ROOT}/cmd/coder"
|
||||
echo "go build -o ${CODER_DEV_BIN} ${PROJECT_ROOT}/enterprise/cmd/coder"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,9 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: ./develop.sh [--agpl]
|
||||
#
|
||||
# If the --agpl parameter is specified, builds only the AGPL-licensed code (no
|
||||
# Coder enterprise features).
|
||||
|
||||
# Allow toggling verbose output
|
||||
[[ -n ${VERBOSE:-""} ]] && set -x
|
||||
set -euo pipefail
|
||||
|
||||
agpl="${CODER_BUILD_AGPL:-0}"
|
||||
args="$(getopt -o "" -l agpl -- "$@")"
|
||||
eval set -- "$args"
|
||||
while true; do
|
||||
case "$1" in
|
||||
--agpl)
|
||||
agpl=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
error "Unrecognized option: $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
source "${SCRIPT_DIR}/lib.sh"
|
||||
|
@ -28,8 +52,13 @@ if [[ ! -e ./site/out/bin/coder.sha1 && ! -e ./site/out/bin/coder.tar.zst ]]; th
|
|||
exit 1
|
||||
fi
|
||||
|
||||
cmd_path="enterprise/cmd/coder"
|
||||
if [[ "$agpl" == 1 ]]; then
|
||||
cmd_path="cmd/coder"
|
||||
fi
|
||||
|
||||
# Compile the CLI binary once just so we don't waste time compiling things multiple times
|
||||
go build -tags embed -o "${CODER_DEV_BIN}" "${PROJECT_ROOT}/cmd/coder"
|
||||
go build -tags embed -o "${CODER_DEV_BIN}" "${PROJECT_ROOT}/${cmd_path}"
|
||||
# Use the coder dev shim so we don't overwrite the user's existing Coder config.
|
||||
CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = {
|
|||
// Run the coder daemon directly.
|
||||
command: `go run -tags embed ${path.join(
|
||||
__dirname,
|
||||
"../../cmd/coder/main.go",
|
||||
"../../enterprise/cmd/coder/main.go",
|
||||
)} server --in-memory`,
|
||||
port: basePort,
|
||||
timeout: 120 * 10000,
|
||||
|
|
Loading…
Reference in New Issue