-
Notifications
You must be signed in to change notification settings - Fork 156
/
extract-docker-binaries.sh
executable file
·108 lines (94 loc) · 4.6 KB
/
extract-docker-binaries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
PROG_NAME=$0
usage() {
cat << EOF >&2
Usage: $PROG_NAME <emp_games|data_processing|pid|validation> [-t TAG] [-d DOCKER_IMAGE_NAME]
package:
emp_games - extracts the binaries from fbpcs/emp-games docker image
data_processing - extracts the binaries from fbpcs/data-processing docker image
pid - extracts the binaries from private-id docker image
validation - extracts the binaries from the onedocker docker image
-t TAG: uses the image with the given tag (default: latest)
-d DOCKER_IMAGE_NAME: defines the image name to extract from
EOF
exit 1
}
PACKAGES="emp_games data_processing pid validation"
PACKAGE=$1
if [[ ! " $PACKAGES " =~ $PACKAGE ]]; then
usage
fi
shift
TAG="latest"
while getopts "t:d:" o; do
case $o in
t) TAG=$OPTARG;;
d) DOCKER_IMAGE_NAME=$OPTARG;;
*) usage
esac
done
shift "$((OPTIND - 1))"
# ensure docker image name does not contain a : (since we apply that below)
if [[ "$DOCKER_IMAGE_NAME" == *":"* ]]; then
echo "Invalid docker image name. Should not include ':' and a tag."
exit 1
fi
# determine what docker image name and tag to use
if [ -z "$DOCKER_IMAGE_NAME" ]; then
case $PACKAGE in
emp_games) DOCKER_IMAGE_NAME="fbpcs/emp-games";;
data_processing) DOCKER_IMAGE_NAME="fbpcs/data-processing";;
pid) DOCKER_IMAGE_NAME="fbpcs/onedocker/test";;
validation) DOCKER_IMAGE_NAME="fbpcs/onedocker/test";;
esac
fi
DOCKER_IMAGE_PATH="${DOCKER_IMAGE_NAME}:${TAG}"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Run from the root dir of so the binaries paths exist
cd "$SCRIPT_DIR" || exit
mkdir -p binaries_out
TEMP_CONTAINER_NAME="temp_container_$TAG"
clean_up_container() {
docker rm -f "$TEMP_CONTAINER_NAME"
}
trap "clean_up_container" EXIT
if [ "$PACKAGE" = "emp_games" ]; then
docker create -ti --name "$TEMP_CONTAINER_NAME" "${DOCKER_IMAGE_PATH}"
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/lift_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pcf2_lift_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pcf2_lift_metadata_compaction "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/udp_encryptor "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/decoupled_attribution_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/decoupled_aggregation_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pcf2_attribution_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pcf2_aggregation_calculator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/shard_aggregator "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pcf2_shard_combiner "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private_id_dfca_aggregator "$SCRIPT_DIR/binaries_out/."
fi
if [ "$PACKAGE" = "data_processing" ]; then
docker create -ti --name "$TEMP_CONTAINER_NAME" "${DOCKER_IMAGE_PATH}"
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/sharder "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/sharder_hashed_for_pid "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/secure_random_sharder "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pid_preparer "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/lift_id_combiner "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/attribution_id_combiner "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private_id_dfca_id_combiner "$SCRIPT_DIR/binaries_out/."
fi
if [ "$PACKAGE" = "pid" ]; then
docker create -ti --name "$TEMP_CONTAINER_NAME" "${DOCKER_IMAGE_PATH}"
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private-id-server "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private-id-client "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private-id-multi-key-server "$SCRIPT_DIR/binaries_out/."
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/private-id-multi-key-client "$SCRIPT_DIR/binaries_out/."
fi
if [ "$PACKAGE" = "validation" ]; then
docker create -ti --name "$TEMP_CONTAINER_NAME" "${DOCKER_IMAGE_PATH}"
docker cp "$TEMP_CONTAINER_NAME":/usr/local/bin/pc_pre_validation_cli "$SCRIPT_DIR/binaries_out/."
fi