# How-to push/copy app folder contents in builder container

**URL:** <https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930>\
**Category:** Product support\
**Tags:** dockerfile\
**Created:** [April 15, 2018, 6:28pm UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930 "2018-04-15T18:28:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bas\_thingshub](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@bas\_thingshub](https://forums.balena.io/u/bas_thingshub)\
**Post date:** [April 15, 2018, 6:28pm UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930/1 "2018-04-15T18:28:54Z")

</div>

When building my golang app ([https://github.com/Bas-ProRail/resin-datacollector-edge](https://github.com/Bas-ProRail/resin-datacollector-edge)) with gradle there is an error, " ./gradlew: not found".

[datacollector] Step 1/6 : FROM resin/iot2000-golang:latest  
[datacollector] —\> 07d5f0804451  
[datacollector] Step 2/6 : ENV INITSYSTEM on  
[datacollector] Using cache  
[datacollector] —\> f9a3449b44ea  
[datacollector] Step 3/6 : COPY . $GOPATH/src/github.com/streamsets  
[datacollector] —\> a0d18d65f287  
[datacollector] Removing intermediate container 9cb7c4995b47  
[datacollector] Step 4/6 : RUN cd $GOPATH/src/github.com/streamsets  
[datacollector] —\> Running in 5bf4700a4860  
[datacollector] —\> f4e869f2669c  
[datacollector] Removing intermediate container 5bf4700a4860  
[datacollector] Step 5/6 : RUN ./gradlew build  
[datacollector] —\> Running in 8552d193a253  
[datacollector] /bin/sh: 1: ./gradlew: not found  
[datacollector]  
[datacollector] Removing intermediate container 8552d193a253  
[datacollector] The command ‘/bin/sh -c ./gradlew build’ returned a non-zero code: 127

Is there a way to check if the COPY command did copy something in $GOPATH/src/github.com/streamsets? It should copy all contents of /resin-datacollector-edge/datacollector-edge in $GOPATH/src/github.com/streamsets.

Thank you for your help, Bas

---

<div class="post-metadata">

**Author:** ![nazrhom](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nazrhom](https://forums.balena.io/u/nazrhom)\
**Post date:** [April 24, 2018, 11:20am UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930/4 "2018-04-24T11:20:10Z")

</div>

Hello Bas,  
sorry for the late reply. I had a look at the repo you linked and it seems like the `Dockerfile` you refer to has changed. Did you manage to solve the issue?

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [April 24, 2018, 12:02pm UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930/5 "2018-04-24T12:02:21Z")

</div>

> [@bas\_thingshub](#):
>
> Is there a way to check if the COPY command did copy something in $GOPATH/src/github.com/streamsets

For testing purposes, you could add a `RUN` line after the command in question to display the contents of the folder:

```auto
COPY . $GOPATH/src/github.com/streamsets
RUN ls -la $GOPATH/src/github.com/streamsets

```

On the other hand, the actual issue is not that, but that you are breaking up your `RUN` command into two lines. The things to keep in mind:

- `WORKDIR` sets where you are in the container by default (can be changed as many times as you want to
- Every `RUN` starts at `WORKDIR` every time

Thus you `RUN cd ...`, but then the next `RUN` won’t be in that folder. In this case there are two ways to work around this:

```auto
FROM resin/iot2000-golang:latest
ENV INITSYSTEM on
WORKDIR $GOPATH/src/github.com/streamsets
COPY . .
RUN ./gradlew build
....

```

and for example set `WORKDIR` later where it is more appropriate.

Or, you can run multiple commands in a single `RUN`, like this:

```auto
FROM resin/iot2000-golang:latest
ENV INITSYSTEM on
COPY . $GOPATH/src/github.com/streamsets
RUN cd $GOPATH/src/github.com/streamsets && \
      ./gradlew build
...

```

Here `&&` says that if the command before that succeeds, the next one will commence. `\` is just a line-break separator, that “the next line is still the same command, so continue”. Thus these two are eqivalent:

```auto
RUN command1 && \
    command2 && \
    command3 && \
    command4

```

and

```auto
RUN command1 && command2 && command3 && command4

```

See more info in the Dockerfile reference for the [`RUN` command](https://docs.docker.com/engine/reference/builder/#run), [`COPY` command](https://docs.docker.com/engine/reference/builder/#copy), and [`WORKDIR` command](https://docs.docker.com/engine/reference/builder/#workdir).

Let us know if this helps!

---

<div class="post-metadata">

**Author:** ![bas\_thingshub](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@bas\_thingshub](https://forums.balena.io/u/bas_thingshub)\
**Post date:** [April 26, 2018, 7:40am UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930/6 "2018-04-26T07:40:52Z")

</div>

> [@imrehg](#):
>
> Let us know if this helps!

Thank you for assisting in this, with your commends I did a big cleanup on my dockerfile.template in

[GitHub - Bas-ProRail/resin-datacollector-edge: Monitoring Siemens S7 PLCs](https://github.com/Bas-ProRail/resin-datacollector-edge) /datacollector-edge/ app

my build with gradle is going great and with some altering in the [streamsets.com](http://streamsets.com) package I end up with a successfull build and a unicorn!

Is there a way to reduce the size of the images the device has to download from the resin buildservers? Can I remove some unnecessary files before issuing the last CMD?

```
[Success] Release successfully created!
[Info] ┌───────────────┬────────────┬───────────────────────┐
[Info] │ Service │ Image Size │ Build Time │
[Info] ├───────────────┼────────────┼───────────────────────┤
[Info] │ s7comm │ 161.84 MB │ < 1 second │
[Info] ├───────────────┼────────────┼───────────────────────┤
[Info] │ datacollector │ 920.80 MB │ 3 minutes, 12 seconds │
[Info] └───────────────┴────────────┴───────────────────────┘
[Info] Build finished in 4 minutes, 7 seconds

```

---

<div class="post-metadata">

**Author:** ![mccollam](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mccollam/32/88_2.png) [@mccollam](https://forums.balena.io/u/mccollam)\
**Post date:** [April 27, 2018, 9:23pm UTC](https://forums.balena.io/t/how-to-push-copy-app-folder-contents-in-builder-container/2930/7 "2018-04-27T21:23:11Z")

</div>

Great, we’re glad to hear that things are working 🙂

You have a couple of options that you can use to reduce the download size. One is just like you said – you can remove any unnecessary files (just `RUN rm <whatever>` in your Dockerfile) at the end of your Dockerfile, before the `CMD` statement. That will shrink your image down some.

Another thing you can do is turn on the [delta](https://docs.resin.io/learn/deploy/delta/) feature. This will cause your device to download only the changes between updates rather than the full image every time. The first download will still take the same amount of time/data, but future downloads will be far faster and smaller.

The best news is that you can use both of these together to help shrink your download time and size!
