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

Add dockerfile to build inside a docker container #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
types/
node_modules/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
types/
node_modules/
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# base Go image version.
FROM golang:1.12-buster

WORKDIR /project

# install some dependencies from apt-get.
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -y && \
apt-get install -y yarn unzip && \
rm -rf /var/lib/apt/lists/*

# install myitcv/gopherjs
RUN git clone https://github.com/myitcv/gopherjs /gopherjs
RUN cd /gopherjs && GO111MODULE=on go install

# install yarn dependencies
COPY package.json yarn.lock ./
RUN yarn install

# copy source
COPY . .
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,29 @@ See [`EXTEND.md`](https://github.com/cosmos/amino-js/blob/extend/EXTEND.md) for
`amino-js` is very new! Questions, feedback, use cases, issues, and code are all very, very welcome.

Thank you for helping us help you help us all. 🎁

### Build inside a Docker Container

If you wish to build this lib without having to install Go 1.12, GopherJS and Yarn on your local computer, you can build it inside a docker container. You only need docker to be installed on your computer.

Run the following commands in the root path of this repository.

#### Build the docker image

```
docker build .
```

### Run yarn in the docker container

You can run any yarn command inside the container. By sharing the current path to the container, any new files will be available on the host.

Run `yarn setup` and `yarn test`:
```
docker run --rm -it -v $(PWD)/dist:/project/dist -v $(PWD)/types:/project/types $(docker build -q .) yarn setup && yarn test
```

Run `yarn publish`:
```
docker run --rm -it -v $(PWD)/dist:/project/dist -v $(PWD)/types:/project/types $(docker build -q .) yarn publish
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"go": "cd go/js && gopherjs build -v -o ../../lib/Amino.js .",
"go:min": "yarn go -m",
"go:watch": "yarn go -w",
"gzip": "gzip -kf dist/*.{js,map}",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed this because it was not working inside the debian docker container.

"gzip": "gzip -kf dist/*.js dist/*.map",
"lint": "eslint --ext .ts,.js .",
"nuke": "rm -rf **/node_modules yarn.lock",
"prepublishOnly": "yarn dirs && yarn lint && yarn tsc && yarn dist:prod && yarn test",
Expand Down