-
Notifications
You must be signed in to change notification settings - Fork 11
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: Build locally in Docker to streamline testing #46
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are created if you run the Dockerfile, since we mount this folder as | ||
# the home directory. | ||
.bash_history | ||
.sudo_as_admin_successful | ||
.wget-hsts | ||
|
||
# Editor swap files | ||
*~ | ||
.*.sw* | ||
|
||
# A local build folder | ||
build |
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,82 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2021 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
# Build everything, assuming we're inside an Ubuntu container. This is useful | ||
# for quick automated builds and for testing build script changes. | ||
|
||
# Build with: | ||
# rm -rf build | ||
# docker run --rm -v $(pwd):/src -w /src ubuntu:24.04 /src/build.sh | ||
# Build outputs are: | ||
# build/ffmpeg/ffmpeg | ||
# build/ffmpeg/ffprobe | ||
|
||
# Fail on error | ||
set -e | ||
# Show commands as they are run | ||
set -x | ||
|
||
if [ ! -e build-scripts ]; then | ||
echo "Must be run from inside the static-ffmpeg-binaries repo." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# If run as root in a container, change to the ubuntu user. This script only | ||
# supports Ubuntu as a container, for simplicity. | ||
if [[ $(id -u) == "0" ]]; then | ||
# If we're on Ubuntu before 24.04, there's no default "ubuntu" user. | ||
# This maps these older versions to the starting state of 24.04+. | ||
groupadd -g 1000 ubuntu || true | ||
useradd -u 1000 -g 1000 -m -d /home/ubuntu ubuntu || true | ||
|
||
# Sudo is needed by the first build script, and vim is for interactive | ||
# debugging and editing in the container. | ||
apt -y update && apt -y upgrade && apt -y install vim sudo | ||
|
||
# Make sudo work without a password. | ||
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
# Create build/ and make it owned by ubuntu inside this Docker container, not | ||
# the current user outside Docker. | ||
rm -rf build | ||
mkdir build | ||
chown ubuntu build | ||
|
||
if [ -z "$GITHUB_ENV" ]; then | ||
# Running outside of GitHub Actions? Set these important variables. | ||
export GITHUB_ENV=/tmp/github.env | ||
export SUDO=sudo | ||
export RUNNER_OS=Linux | ||
fi | ||
|
||
# Preserve the environment (-p), which contains important variables like | ||
# RUNNER_OS, etc. | ||
exec su -p ubuntu "$0" "$@" | ||
fi | ||
|
||
# If we are running outside a container, we may not have hit the "root" branch | ||
# above. Create the build/ folder if it doesn't exist. | ||
mkdir -p build | ||
|
||
# Set up the same symlink we get from our GitHub workflow, expected by the | ||
# build scripts. | ||
cd build | ||
ln -s ../ repo-src | ||
|
||
# Run each build script in order. | ||
for SCRIPT in ./repo-src/build-scripts/*; do | ||
"$SCRIPT" || exit 1 | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; for clarity, specify this is creating a user with a username/password of "ubuntu"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not creating a password at all. That user would be unable to log in with a password. I'll try to clarify the comment.