Skip to content

Commit 479a592

Browse files
Support new version policy in installers
Tarantool download through the installer [1] has changed along with the announcement of the new release policy. cartridge pack docker command uses an installer to install Tarantool. Based on commit 95daacb by @mRrvz (original version of #629 PR). 1. https://tarantool.io/installer.sh Closes #619
1 parent 2aaab5f commit 479a592

File tree

7 files changed

+98
-29
lines changed

7 files changed

+98
-29
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3535
- Removed unnecessary flags (``--rocks``, ``--project-path``) from ``cartridge help`` command.
3636
- Fixed project build with capital letters in the project name.
3737
- Fixed display of Docker image pull (``cartridge pack`` command with ``--verbose`` flag).
38+
- Added support for new Tarantool release policy.
3839

3940
### Added
4041

cli/project/dockerfiles.go

+30-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ func init() {
2121
}
2222

2323
type opensourseCtx struct {
24-
MajorMinorVersion string
24+
// Type is "release" or "pre-release".
25+
Type string
26+
// Version is "<Major>.<Minor>" for <= 2.8, "<Major>" for newer versions.
27+
Version string
2528
}
2629

2730
type enterpriseCtx struct {
@@ -154,6 +157,7 @@ func CheckBaseDockerfile(dockerfilePath string) error {
154157

155158
func getInstallTarantoolLayers(ctx *context.Ctx) (string, error) {
156159
var installTarantoolLayers string
160+
var version common.TarantoolVersion
157161
var err error
158162

159163
if ctx.Tarantool.TarantoolIsEnterprise {
@@ -167,9 +171,16 @@ func getInstallTarantoolLayers(ctx *context.Ctx) (string, error) {
167171

168172
} else {
169173
tmplStr := installTarantoolOpensourceLayers
174+
175+
version, err = common.ParseTarantoolVersion(ctx.Tarantool.TarantoolVersion)
176+
if err != nil {
177+
return "", err
178+
}
179+
170180
installTarantoolLayers, err = templates.GetTemplatedStr(&tmplStr,
171181
opensourseCtx{
172-
MajorMinorVersion: common.GetMajorMinorVersion(ctx.Tarantool.TarantoolVersion),
182+
Type: getInstallerType(version),
183+
Version: getVersionForTarantoolInstaller(version),
173184
},
174185
)
175186

@@ -181,6 +192,22 @@ func getInstallTarantoolLayers(ctx *context.Ctx) (string, error) {
181192
return installTarantoolLayers, nil
182193
}
183194

195+
func getVersionForTarantoolInstaller(version common.TarantoolVersion) string {
196+
if (version.Major == 2 && version.Minor <= 8) || version.Major < 2 {
197+
return fmt.Sprintf("%d.%d", version.Major, version.Minor)
198+
}
199+
200+
return fmt.Sprintf("%d", version.Major)
201+
}
202+
203+
func getInstallerType(version common.TarantoolVersion) string {
204+
if version.TagSuffix != "" {
205+
return "pre-release"
206+
}
207+
208+
return "release"
209+
}
210+
184211
const (
185212
DefaultBaseBuildDockerfile = "Dockerfile.build.cartridge"
186213
DefaultBaseRuntimeDockerfile = "Dockerfile.cartridge"
@@ -224,7 +251,7 @@ ENV TARANTOOL_INSTANCE_NAME=default
224251
`
225252

226253
installTarantoolOpensourceLayers = `### Install opensource Tarantool
227-
RUN curl -L https://tarantool.io/installer.sh | VER={{ .MajorMinorVersion }} bash \
254+
RUN curl -L https://tarantool.io/installer.sh | VER={{ .Version }} bash -s -- --type {{ .Type }} \
228255
&& yum -y install tarantool-devel
229256
`
230257

cli/project/dockerfiles_test.go

+37-11
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ ENV PATH="/usr/share/tarantool/sdk:${PATH}"
9292

9393
// Tarantool Opensource 2.1
9494
ctx.Tarantool.TarantoolIsEnterprise = false
95-
ctx.Tarantool.TarantoolVersion = "2.1.42"
95+
ctx.Tarantool.TarantoolVersion = "2.1.42-0-g1fa53afe3"
9696

9797
expLayers = `### Install opensource Tarantool
98-
RUN curl -L https://tarantool.io/installer.sh | VER=2.1 bash \
98+
RUN curl -L https://tarantool.io/installer.sh | VER=2.1 bash -s -- --type release \
9999
&& yum -y install tarantool-devel
100100
`
101101

@@ -105,10 +105,36 @@ RUN curl -L https://tarantool.io/installer.sh | VER=2.1 bash \
105105

106106
// Tarantool Opensource 1.10
107107
ctx.Tarantool.TarantoolIsEnterprise = false
108-
ctx.Tarantool.TarantoolVersion = "1.10.42"
108+
ctx.Tarantool.TarantoolVersion = "1.10.42-0-gfa53a1fe3"
109109

110110
expLayers = `### Install opensource Tarantool
111-
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash \
111+
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash -s -- --type release \
112+
&& yum -y install tarantool-devel
113+
`
114+
115+
layers, err = getInstallTarantoolLayers(&ctx)
116+
assert.Nil(err)
117+
assert.Equal(expLayers, layers)
118+
119+
// Tarantool Opensource 2.10 pre-release
120+
ctx.Tarantool.TarantoolIsEnterprise = false
121+
ctx.Tarantool.TarantoolVersion = "2.10.0-beta1-0-g7da4b1438"
122+
123+
expLayers = `### Install opensource Tarantool
124+
RUN curl -L https://tarantool.io/installer.sh | VER=2 bash -s -- --type pre-release \
125+
&& yum -y install tarantool-devel
126+
`
127+
128+
layers, err = getInstallTarantoolLayers(&ctx)
129+
assert.Nil(err)
130+
assert.Equal(expLayers, layers)
131+
132+
// Tarantool Opensource 2.10
133+
ctx.Tarantool.TarantoolIsEnterprise = false
134+
ctx.Tarantool.TarantoolVersion = "2.10.3-0-gb14387da4"
135+
136+
expLayers = `### Install opensource Tarantool
137+
RUN curl -L https://tarantool.io/installer.sh | VER=2 bash -s -- --type release \
112138
&& yum -y install tarantool-devel
113139
`
114140

@@ -218,7 +244,7 @@ func TestGetBuildImageDockerfileTemplateOpensource(t *testing.T) {
218244

219245
// Tarantool Opensource 1.10 w/o --build-from
220246
ctx.Tarantool.TarantoolIsEnterprise = false
221-
ctx.Tarantool.TarantoolVersion = "1.10.42"
247+
ctx.Tarantool.TarantoolVersion = "1.10.42-0-gfa53a1fe3"
222248
ctx.Build.DockerFrom = ""
223249

224250
expLayers = `FROM centos:7
@@ -227,7 +253,7 @@ func TestGetBuildImageDockerfileTemplateOpensource(t *testing.T) {
227253
RUN yum install -y git-core gcc gcc-c++ make cmake unzip
228254
229255
### Install opensource Tarantool
230-
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash \
256+
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash -s -- --type release \
231257
&& yum -y install tarantool-devel
232258
233259
### Wrap user
@@ -254,7 +280,7 @@ RUN yum install -y zip
254280
writeDockerfile(f, baseDockerfileContent)
255281

256282
ctx.Tarantool.TarantoolIsEnterprise = false
257-
ctx.Tarantool.TarantoolVersion = "1.10.42"
283+
ctx.Tarantool.TarantoolVersion = "1.10.42-0-gfa53a1fe3"
258284
ctx.Build.DockerFrom = f.Name()
259285

260286
expLayers = `FROM centos:7
@@ -264,7 +290,7 @@ RUN yum install -y zip
264290
RUN yum install -y git-core gcc gcc-c++ make cmake unzip
265291
266292
### Install opensource Tarantool
267-
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash \
293+
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash -s -- --type release \
268294
&& yum -y install tarantool-devel
269295
270296
### Wrap user
@@ -417,7 +443,7 @@ func TestGetRuntimeImageDockerfileTemplateOpensource(t *testing.T) {
417443

418444
// Tarantool Opensource 1.10 w/o --from
419445
ctx.Tarantool.TarantoolIsEnterprise = false
420-
ctx.Tarantool.TarantoolVersion = "1.10.42"
446+
ctx.Tarantool.TarantoolVersion = "1.10.42-0-gfa53a1fe3"
421447
ctx.Pack.DockerFrom = ""
422448

423449
expLayers = `FROM centos:7
@@ -428,7 +454,7 @@ RUN groupadd -r -g {{ .TarantoolGID }} tarantool \
428454
-c "Tarantool Server" tarantool
429455
430456
### Install opensource Tarantool
431-
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash \
457+
RUN curl -L https://tarantool.io/installer.sh | VER=1.10 bash -s -- --type release \
432458
&& yum -y install tarantool-devel
433459
434460
### Prepare for runtime
@@ -463,7 +489,7 @@ RUN yum install -y zip
463489
writeDockerfile(f, baseDockerfileContent)
464490

465491
ctx.Tarantool.TarantoolIsEnterprise = false
466-
ctx.Tarantool.TarantoolVersion = "1.10.42"
492+
ctx.Tarantool.TarantoolVersion = "1.10.42-0-gfa53a1fe3"
467493
ctx.Pack.DockerFrom = f.Name()
468494

469495
expLayers = `FROM centos:7

test/e2e/test_deb.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from project import INIT_CHECK_PASSED_PARAMS, replace_project_file
88
from utils import (Archive, ProjectContainer, build_image,
99
check_contains_regular_file, check_systemd_service,
10-
delete_image, find_archive, run_command_on_container,
11-
tarantool_enterprise_is_used, tarantool_short_version)
10+
delete_image, find_archive, get_tarantool_installer_cmd,
11+
run_command_on_container, tarantool_enterprise_is_used)
1212

1313

1414
# ########
@@ -84,10 +84,11 @@ def container_with_installed_deb(docker_client, deb_archive_with_cartridge,
8484

8585
dockerfile_layers = ["FROM jrei/systemd-ubuntu"]
8686
if not tarantool_enterprise_is_used():
87+
tarantool_install_cmd = get_tarantool_installer_cmd("apt-get")
8788
dockerfile_layers.append('''RUN apt-get update && apt-get install -y curl \
8889
&& DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata \
89-
&& curl -L https://tarantool.io/installer.sh | VER={} bash
90-
'''.format(tarantool_short_version()))
90+
&& {}
91+
'''.format(tarantool_install_cmd))
9192
else:
9293
dockerfile_layers.append("RUN apt-get update")
9394

test/e2e/test_rpm.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import pytest
66
from utils import (Archive, ProjectContainer, build_image,
77
check_contains_regular_file, check_systemd_service,
8-
delete_image, find_archive, run_command_on_container,
9-
tarantool_enterprise_is_used, tarantool_short_version)
8+
delete_image, find_archive, get_tarantool_installer_cmd,
9+
run_command_on_container, tarantool_enterprise_is_used)
1010

1111

1212
# ########
@@ -65,9 +65,8 @@ def container_with_installed_rpm(docker_client, rpm_archive_with_cartridge,
6565

6666
dockerfile_layers = ["FROM centos:7"]
6767
if not tarantool_enterprise_is_used():
68-
dockerfile_layers.append('''RUN curl -L \
69-
https://tarantool.io/installer.sh | VER={} bash
70-
'''.format(tarantool_short_version()))
68+
installer_cmd = get_tarantool_installer_cmd("yum")
69+
dockerfile_layers.append(f"RUN {installer_cmd}")
7170
else:
7271
dockerfile_layers.append("RUN yum update -y")
7372

test/e2e/test_tgz.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
ROUTER_WITH_EVAL_FILEPATH, replace_project_file)
1010
from utils import (Archive, InstanceContainer, build_image, delete_image,
1111
examine_application_instance_container, find_archive,
12-
run_command_on_container, tarantool_enterprise_is_used,
13-
tarantool_short_version)
12+
get_tarantool_installer_cmd, run_command_on_container,
13+
tarantool_enterprise_is_used)
1414

1515

1616
# ########
@@ -49,10 +49,8 @@ def instance_container_with_unpacked_tgz(docker_client, tmpdir, tgz_archive_with
4949

5050
dockerfile_layers = ["FROM centos:7"]
5151
if not tarantool_enterprise_is_used():
52-
dockerfile_layers.append('''RUN curl -L \
53-
https://tarantool.io/installer.sh | VER={} bash
54-
'''.format(tarantool_short_version()))
55-
52+
tarantool_installer = get_tarantool_installer_cmd("yum")
53+
dockerfile_layers.append(f"RUN {tarantool_installer}")
5654
with open(os.path.join(build_path, 'Dockerfile'), 'w') as f:
5755
f.write('\n'.join(dockerfile_layers))
5856

test/utils.py

+17
Original file line numberDiff line numberDiff line change
@@ -1421,3 +1421,20 @@ def tarantool_dict_version():
14211421
assert ver['IsDevelopmentBuild'] is False
14221422

14231423
return ver
1424+
1425+
1426+
def get_tarantool_installer_cmd(package_manager):
1427+
ver = tarantool_dict_version()
1428+
1429+
tarantool_type = "release"
1430+
if (ver['Major'] == 2 and ver['Minor'] <= 8) or ver['Major'] < 2:
1431+
short_version = f"{ver['Major']}.{ver['Minor']}"
1432+
else:
1433+
short_version = f"{ver['Major']}"
1434+
1435+
if ver['TagSuffix'] is not None:
1436+
tarantool_type = "pre-release"
1437+
1438+
return f"curl -L https://tarantool.io/installer.sh | \
1439+
VER={short_version} bash -s -- --type {tarantool_type} \
1440+
&& {package_manager} install -y tarantool"

0 commit comments

Comments
 (0)