Skip to content

Commit f94f9d8

Browse files
committed
ballerina: bump version and add support for arm64
1 parent dc7f4d1 commit f94f9d8

File tree

4 files changed

+73
-8
lines changed

4 files changed

+73
-8
lines changed

ballerina/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# Copyright 2019 tsuru authors. All rights reserved.
1+
# Copyright 2025 tsuru authors. All rights reserved.
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
FROM tsuru/base-platform:22.04
5+
FROM tsuru/base-platform:24.04
66
COPY . /var/lib/tsuru/ballerina
77
RUN set -ex \
88
&& sudo cp /var/lib/tsuru/ballerina/deploy /var/lib/tsuru \
9-
&& sudo /var/lib/tsuru/ballerina/install \
10-
&& sudo rm -rf /var/lib/apt/lists/*
9+
&& sudo /var/lib/tsuru/ballerina/install

ballerina/deploy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file.
66

7+
# Set JAVA_HOME for Ballerina
8+
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-arm64
9+
export PATH=$PATH:/usr/local/bin
10+
711
SOURCE_DIR=/var/lib/tsuru
812
source ${SOURCE_DIR}/base/deploy
913
source ${SOURCE_DIR}/base/rc/config

ballerina/install

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
#!/bin/bash -el
22

3-
# Copyright 2019 tsuru authors. All rights reserved.
3+
# Copyright 2025 tsuru authors. All rights reserved.
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file.
66
set -eu -o pipefail
77

8-
curl -fsSL -o /tmp/ballerina.deb https://dist.ballerina.io/downloads/2201.0.3/ballerina-2201.0.3-swan-lake-linux-x64.deb
9-
dpkg -i /tmp/ballerina.deb
10-
rm -f /tmp/ballerina.deb
8+
BALLERINA_VERSION=2201.13.1
9+
10+
# Install Java 21 and unzip (required by Ballerina)
11+
apt-get update
12+
apt-get install -y --no-install-recommends openjdk-21-jdk-headless unzip
13+
apt-get clean
14+
rm -rf /var/lib/apt/lists/*
15+
16+
# Download and install Ballerina
17+
curl -fsSL -o /tmp/ballerina.zip https://dist.ballerina.io/downloads/${BALLERINA_VERSION}/ballerina-${BALLERINA_VERSION}-swan-lake.zip
18+
unzip -q /tmp/ballerina.zip -d /opt/
19+
rm -f /tmp/ballerina.zip
20+
21+
# Create wrapper script for bal that sets JAVA_HOME
22+
cat > /usr/local/bin/bal <<BAL_WRAPPER
23+
#!/bin/bash
24+
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-arm64
25+
exec /opt/ballerina-${BALLERINA_VERSION}-swan-lake/bin/bal "\$@"
26+
BAL_WRAPPER
27+
chmod +x /usr/local/bin/bal
28+
29+
# Set JAVA_HOME environment variable for system-wide use
30+
echo "export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-arm64" >> /etc/environment

tests/ballerina/tests.bats

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bats
2+
3+
# Copyright 2025 tsuru authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style
5+
# license that can be found in the LICENSE file.
6+
7+
setup() {
8+
rm -rf /home/application/current && mkdir -p /home/application/current
9+
chown ubuntu /home/application/current
10+
export CURRENT_DIR=/home/application/current
11+
export PATH=/usr/local/bin:${PATH}
12+
}
13+
14+
load 'bats-support-master/load'
15+
load 'bats-assert-master/load'
16+
17+
@test "ensure Ballerina is installed" {
18+
run bal version
19+
assert_success
20+
[[ "$output" == *"Ballerina 2201.13.1"* ]]
21+
}
22+
23+
@test "bal command is available in PATH" {
24+
run which bal
25+
assert_success
26+
[[ "$output" == "/usr/local/bin/bal" ]]
27+
}
28+
29+
@test "deploy simple Ballerina service" {
30+
cat <<EOF >${CURRENT_DIR}/hello_service.bal
31+
import ballerina/http;
32+
33+
service /hello on new http:Listener(8888) {
34+
resource function get sayHello() returns string {
35+
return "Hello Ballerina!";
36+
}
37+
}
38+
EOF
39+
40+
run /var/lib/tsuru/deploy
41+
assert_success
42+
}

0 commit comments

Comments
 (0)