Skip to content

Commit

Permalink
Improve container image startup parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mering committed Jun 21, 2023
1 parent db0775a commit cf76210
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

java -jar /opt/copybara/copybara_deploy.jar $COPYBARA_OPTIONS $COPYBARA_SUBCOMMAND $COPYBARA_CONFIG $COPYBARA_WORKFLOW $COPYBARA_SOURCEREF
exec java -jar /opt/copybara/copybara_deploy.jar "$@"
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ RUN go install github.com/bazelbuild/buildtools/buildifier@latest
FROM openjdk:11-jre-slim
COPY --from=build /home/ubuntu/bazel-bin/java/com/google/copybara/copybara_deploy.jar /opt/copybara/
COPY --from=buildtools /go/bin/buildozer /go/bin/buildifier /usr/bin/
COPY .docker/entrypoint.sh /usr/local/bin/copybara
RUN chmod +x /usr/local/bin/copybara
COPY .docker/entrypoint.sh /entrypoint
RUN chmod +x /entrypoint
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
ENTRYPOINT ["/entrypoint"]
CMD ["migrate", "copy.bara.sky"]
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,15 @@ Once this has finished building, you can run the image like so from the root of
the code you are trying to use Copybara on:

```sh
docker run -it -v "$(pwd)":/usr/src/app copybara copybara
docker run -it -v "$(pwd)":/usr/src/app copybara
```

A few environment variables exist to allow you to change how you run copybara:
* `COPYBARA_CONFIG=copy.bara.sky`
* allows you to specify a path to a config file, defaults to root `copy.bara.sky`
* `COPYBARA_SUBCOMMAND=migrate`
* allows you to change the command run, defaults to `migrate`
* `COPYBARA_OPTIONS=''`
* allows you to specify options for copybara, defaults to none
* `COPYBARA_WORKFLOW=default`
* allows you to specify the workflow to run, defaults to `default`
* `COPYBARA_SOURCEREF=''`
* allows you to specify the sourceref, defaults to none

```sh
docker run \
-e COPYBARA_CONFIG='other.config.sky' \
-e COPYBARA_SUBCOMMAND='validate' \
-v "$(pwd)":/usr/src/app \
-it copybara copybara
-it copybara
```

#### Git Config and Credentials
Expand All @@ -200,7 +188,7 @@ docker run \
-v ~/.ssh:/root/.ssh \
-v ~/.gitconfig:/root/.gitconfig \
-v "$(pwd)":/usr/src/app \
-it copybara copybara
-it copybara
```

## Documentation
Expand Down

0 comments on commit cf76210

Please sign in to comment.