Skip to content

Commit 9eca81c

Browse files
authored
Merge pull request #22 from mendix/1090800_shrink_docker_image
Shrink the docker image by cleaning cache and temporary files.
2 parents 2ebf558 + 9e5a91a commit 9eca81c

9 files changed

+58
-62
lines changed

.travis.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ language: sh
55
services:
66
- docker
77

8-
env:
9-
DOCKER_COMPOSE_VERSION: 1.4.2
10-
118
before_install:
12-
- sudo rm /usr/local/bin/docker-compose
13-
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
14-
- chmod +x docker-compose
15-
- sudo mv docker-compose /usr/local/bin
16-
- sudo apt-get install -y python-virtualenv curl
9+
- sudo apt-get update
10+
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine
1711

1812
script:
1913
- bash ./.travistest.sh

.travistest.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
set -eux
3+
docker version
4+
docker-compose version
35
make get-sample
46
make build-image
57
tests/test-generic.sh tests/docker-compose-postgres.yml

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# Mendix Deployment Archive (aka mda file)
33
#
44
# Author: Mendix Digital Ecosystems, [email protected]
5-
# Version: 1.1
6-
5+
# Version: 1.2
76
FROM ubuntu:trusty
87
MAINTAINER Mendix Digital Ecosystems <[email protected]>
98

@@ -30,9 +29,10 @@ ENV PYTHONPATH "/buildpack/lib/"
3029
RUN mkdir build cache
3130
COPY $BUILD_PATH build
3231

33-
# Compile the application source code
32+
# Compile the application source code and remove temp files
3433
WORKDIR /buildpack
35-
RUN "/buildpack/compilation" /build /cache
34+
RUN "/buildpack/compilation" /build /cache && \
35+
rm -fr /cache /tmp/javasdk /tmp/opt
3636

3737
# Expose nginx port
3838
ENV PORT 80

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ get-sample:
44
mkdir -p downloads build
55
wget https://cdn.mendix.com/sample/SampleAppA.mpk -O downloads/application.mpk
66
unzip downloads/application.mpk -d build/
7+
78
build-image:
89
docker build \
910
--build-arg BUILD_PATH=build \
10-
-t mendix/mendix-buildpack:v1 .
11+
-t mendix/mendix-buildpack:v1.2 .
12+
1113
test-container:
1214
tests/test-generic.sh tests/docker-compose-postgres.yml
1315
tests/test-generic.sh tests/docker-compose-sqlserver.yml
1416
tests/test-generic.sh tests/docker-compose-azuresql.yml
15-
run-test-container:
16-
docker-compose -f tests/docker-compose-postgres.yml
17+
18+
run-container:
19+
docker-compose -f tests/docker-compose-postgres.yml up

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The Mendix Buildpack for Docker (aka docker-mendix-buildpack) provides a standar
99
## Try a sample mendix application
1010

1111
Open a terminal and run the following code
12+
1213
```
1314
git clone https://github.com/mendix/docker-mendix-buildpack
1415
cd docker-mendix-buildpack
@@ -17,7 +18,7 @@ make build-image
1718
make run-container
1819
```
1920

20-
You can now open you browser http://localhost:8080
21+
You can now open you browser [http://localhost:8080]([http://localhost:8080])
2122

2223
## Uses cases scenarios:
2324

@@ -31,6 +32,7 @@ This project is goto reference for the following scenarios :
3132
### Requirements
3233

3334
* Docker (Installation [here](https://docs.docker.com/engine/installation/))
35+
* For preparing, a local installation of wget (for macOS)
3436
* For local testing, make sure you can run the [docker-compose command](https://docs.docker.com/compose/install/)
3537

3638
## Usage
@@ -41,7 +43,7 @@ Before running the container, it is necessary to build the image with your appli
4143

4244
```
4345
docker build --build-arg BUILD_PATH=<mendix-project-location> \
44-
-t mendix/mendix-buildpack:v1 .
46+
-t mendix/mendix-buildpack:v1.2 .
4547
```
4648

4749
### Startup
@@ -54,7 +56,7 @@ and the **DATABASE_ENDPOINT** as you can see in the example below:
5456
docker run -it \
5557
-e ADMIN_PASSWORD=Password1! \
5658
-e DATABASE_ENDPOINT=postgres://username:password@host:port/mendix \
57-
mendix/mendix-buildpack:v1
59+
mendix/mendix-buildpack:v1.2
5860
```
5961

6062
or for Microsoft SQL server
@@ -63,12 +65,12 @@ or for Microsoft SQL server
6365
docker run -it \
6466
-e ADMIN_PASSWORD=Password1! \
6567
-e DATABASE_ENDPOINT=sqlserver://username:password@host:port/mendix \
66-
mendix/mendix-buildpack:v1
68+
mendix/mendix-buildpack:v1.2
6769
```
6870

6971
## Features
7072

71-
This project uses the same base technology than Mendix uses to run application in Cloud Foundry (the [mendix cloudfoundry buildpack](https://github.com/mendix/cf-mendix-buildpack)).
73+
This project uses the same base technology that Mendix uses to run application in Cloud Foundry (the [mendix cloudfoundry buildpack](https://github.com/mendix/cf-mendix-buildpack)).
7274

7375
* Compilation of a Mendix application from project sources
7476
* Automatic generation of the configuration (_m2ee.yaml_)
@@ -83,25 +85,28 @@ This project uses the same base technology than Mendix uses to run application i
8385
### Enabling licensed
8486

8587
If you wish to start your application with a non-trial license, please provide the additional environment variables
88+
8689
* LICENSE_ID
8790
* LICENSE_KEY
8891

8992
example:
93+
9094
```
9195
docker run -it \
9296
-p 8080:80 \
9397
-e ADMIN_PASSWORD=Password1! \
9498
-e DATABASE_ENDPOINT=postgres://mendix:[email protected]:5432/mendix \
9599
-e LICENSE_ID=<UUID> \
96100
-e LICENSE_KEY=<LICENSE_KEY> \
97-
mendix/mendix-buildpack:v1
101+
mendix/mendix-buildpack:v1.2
98102
```
99103

100104
### Passing environment variables to your Mendix runtine
101105

102106
The default values for constants will be used as defined in your project. However, you can override them with environment variables. You need to replace the dot with an underscore and prefix it with MX_. So a constant like Module.Constant with value ABC123 could be set like this:
103107

104108
example:
109+
105110
```
106111
docker run -it \
107112
-p 8080:80 \
@@ -110,7 +115,7 @@ docker run -it \
110115
-e MX_Module_Constant=ABC123 \
111116
-e LICENSE_ID=<UUID> \
112117
-e LICENSE_KEY=<LICENSE_KEY> \
113-
mendix/mendix-buildpack:v1
118+
mendix/mendix-buildpack:v1.2
114119
```
115120

116121
### Configuring Custom Runtime Settings
@@ -120,13 +125,14 @@ To configure any of the advanced Custom Runtime Settings you can use setting nam
120125
For example, to configure the ConnectionPoolingMinIdle setting to value 10, you can set the following environment variable:
121126

122127
example:
128+
123129
```
124130
docker run -it \
125131
-p 8080:80 \
126132
-e ADMIN_PASSWORD=Password1! \
127133
-e DATABASE_ENDPOINT=postgres://mendix:[email protected]:5432/mendix \
128134
-e MXRUNTIME_ConnectionPoolingMinIdle 10 \
129-
mendix/mendix-buildpack:v1
135+
mendix/mendix-buildpack:v1.2
130136
```
131137

132138
If the setting contains a dot . you can use an underscore _ in the environment variable. So to set com.mendix.storage.s3.EndPoint to foo you can use:
@@ -149,7 +155,7 @@ docker run -it \
149155
-e ADMIN_PASSWORD=Password1! \
150156
-e DATABASE_ENDPOINT=postgres://mendix:[email protected]:5432/mendix \
151157
-e SCHEDULED_EVENTS=ALL \
152-
mendix/mendix-buildpack:v1
158+
mendix/mendix-buildpack:v1.2
153159
```
154160

155161
### Configuring Application log levels
@@ -161,6 +167,7 @@ Configuring log levels happens by adding one or more environment variables start
161167
}
162168

163169
You can see the available Log Nodes in your application in the Mendix Modeler. The level should be one of:
170+
164171
* `CRITICAL`
165172
* `ERROR`
166173
* `WARNING`
@@ -177,7 +184,7 @@ docker run -it \
177184
-e ADMIN_PASSWORD=Password1! \
178185
-e DATABASE_ENDPOINT=postgres://mendix:[email protected]:5432/mendix \
179186
-e LOGGING_CONFIG='{"Core": "DEBUG"}' \
180-
mendix/mendix-buildpack:v1
187+
mendix/mendix-buildpack:v1.2
181188
```
182189

183190
## Contributions

tests/docker-compose-azuresql.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
version: '2.1'
1+
mendixapp:
2+
image: mendix/mendix-buildpack:v1.2
3+
environment:
4+
- ADMIN_PASSWORD=Password1!
5+
- DATABASE_ENDPOINT=jdbc:sqlserver://db:1433;database=mendix;user=sa;password=Password1!
6+
ports:
7+
- 8080:80
8+
- 8090:81
9+
links:
10+
- db
211

3-
services:
4-
mendixapp:
5-
image: mendix/mendix-buildpack:v1
6-
depends_on:
7-
- db
8-
environment:
9-
- ADMIN_PASSWORD=Password1!
10-
- DATABASE_ENDPOINT=jdbc:sqlserver://db:1433;database=mendix;user=sa;password=Password1!
11-
ports:
12-
- 8080:80
13-
- 8090:81
14-
links:
15-
- db
16-
17-
db:
18-
image: mendix/mendix_test_sqlserver:v1
12+
db:
13+
image: mendix/mendix_test_sqlserver:v1

tests/docker-compose-postgres.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mendixapp:
2-
image: mendix/mendix-buildpack:v1
2+
image: mendix/mendix-buildpack:v1.2
33
environment:
44
- ADMIN_PASSWORD=Password1!
55
- DATABASE_ENDPOINT=postgres://mendix:mendix@db:5432/mendix

tests/docker-compose-sqlserver.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
version: '2.1'
1+
mendixapp:
2+
image: mendix/mendix-buildpack:v1.2
3+
environment:
4+
- ADMIN_PASSWORD=Password1!
5+
- DATABASE_ENDPOINT=sqlserver://sa:Password1!@db:1433/mendix
6+
ports:
7+
- 8080:80
8+
- 8090:81
9+
links:
10+
- db
211

3-
services:
4-
mendixapp:
5-
image: mendix/mendix-buildpack:v1
6-
depends_on:
7-
- db
8-
environment:
9-
- ADMIN_PASSWORD=Password1!
10-
- DATABASE_ENDPOINT=sqlserver://sa:Password1!@db:1433/mendix
11-
ports:
12-
- 8080:80
13-
- 8090:81
14-
links:
15-
- db
16-
17-
db:
18-
image: mendix/mendix_test_sqlserver:v1
12+
db:
13+
image: mendix/mendix_test_sqlserver:v1

tests/test-generic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ curl http://localhost:8080 | grep "<title>Mendix</title>"
1111
RETURN_CODE=$?
1212
if [ $RETURN_CODE -eq "0" ]; then
1313
echo "test.sh [TEST SUCCESS] App is reachable for $COMPOSEFILE"
14-
docker-compose -f $COMPOSEFILE down
14+
docker-compose -f $COMPOSEFILE kill
1515
else
1616
echo "test.sh [TEST FAILED] App is not reachable in timeout delay $TIMEOUT for $COMPOSEFILE"
17-
docker-compose -f $COMPOSEFILE down
17+
docker-compose -f $COMPOSEFILE kill
1818
fi
1919
exit $RETURN_CODE

0 commit comments

Comments
 (0)