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

Fixes #18 Docker for wrapper java #19

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions docker/images/dev-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM maven:3-jdk-8

RUN apt-get update && apt-get --assume-yes install openjdk-8-jdk-headless && apt-get install --assume-yes openjdk-8-jdk
WORKDIR /usr/src/skyapi
COPY ./lib/skyapi .
RUN mvn clean install
49 changes: 49 additions & 0 deletions docker/images/dev-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Supported tags and respective `Dockerfile` links

## Simple Tags

- [`develop, dind, vscode, vscode-dind` (*docker/images/dev-cli/Dockerfile*)](https://github.com/simelo/libskycoin-dotnet/blob/develop/docker/images/dev-cli/Dockerfile)

# LibJava-Skycoin .NET CLI development image

This image has the necessary tools to build, test, edit, lint and version the Libskycoin .NET
source code. It comes with Vim editor installed, along with some plugins
to ease go development and version control with git.

# How to use this image

## Initialize your development environment.

```sh
$ mkdir src
$ docker run --rm \
-v ${PWD}/src:/usr/local/src skycoin/skycoindev-java:develop \
git clone https://github.com/simelo/libjava-skycoin.git \
$ sudo chown -R `whoami` src
```

This downloads the libjava source to src/libjav and changes the owner
to your user. This is necessary, because all processes inside the container run
as root and the files created by it are therefore owned by root.

## Running commands inside the container

You can run commands by just passing the them to the image. Everything is run
in a container and deleted when finished.

### Running tests

```sh
$ docker run --rm \
-v ${PWD}/src:/usr/local/src simelotech/skycoindev-java:develop \
sh -c "cd libskycoin-java; make test"
```

### Editing code

```sh
$ docker run --rm \
-v ${PWD}/src:/usr/local/src simelotech/skycoindev-java:develop \
vim
```

43 changes: 43 additions & 0 deletions docker/images/dev-cli/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# This are the git ENV vars present at this point for the build process.
# more on that in https://docs.docker.com/docker-cloud/builds/advanced
#
# SOURCE_BRANCH: the name of the branch or the tag that is currently being tested.
# SOURCE_COMMIT: the SHA1 hash of the commit being tested.
# COMMIT_MSG: the message from the commit being tested and built.
# DOCKERFILE_PATH: the dockerfile currently being built.
# DOCKER_REPO: the name of the Docker repository being built.
# CACHE_TAG: the Docker repository tag being built.
# IMAGE_NAME: the name and tag of the Docker repository being built.
# (This variable is a combination of DOCKER_REPO:CACHE_TAG.)

echo "Build hook running"

# Build :develop tag
docker build --build-arg BDATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg SCOMMIT=$SOURCE_COMMIT \
-f $DOCKERFILE_PATH \
-t "$IMAGE_NAME" .

# Build :dind, :vscode and :vscode-dind tag
# Only build if
if [ "$CACHE_TAG" -eq "develop" ]; then
docker build --build-arg IMAGE_FROM="skycoin/skycoindev-cli:dind" \
--build-arg BDATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg SCOMMIT=$SOURCE_COMMIT \
-f $DOCKERFILE_PATH \
-t "$DOCKER_REPO:dind" .

docker build --build-arg IMAGE_FROM="skycoin/skycoindev-vscode:develop" \
--build-arg BDATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg SCOMMIT=$SOURCE_COMMIT \
-f $DOCKERFILE_PATH \
-t "$DOCKER_REPO:vscode" .

docker build --build-arg IMAGE_FROM="skycoin/skycoindev-vscode:dind" \
--build-arg BDATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg SCOMMIT=$SOURCE_COMMIT \
-f $DOCKERFILE_PATH \
-t "$DOCKER_REPO:vscode-dind" .
fi
9 changes: 9 additions & 0 deletions docker/images/dev-cli/hooks/push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

docker push $IMAGE_NAME

if [ "$CACHE_TAG" -eq "develop" ]; then
docker push $DOCKER_REPO:dind
docker push $DOCKER_REPO:vscode
docker push $DOCKER_REPO:vscode-dind
fi