Skip to content

Commit

Permalink
Fix service template updates (#184)
Browse files Browse the repository at this point in the history
* Optimize README

* Fix ASP.NET template

* Update service template versions

* Fix predefined service template updates

* Fix tests

* Fix ASP.NET template
  • Loading branch information
marcauberer committed Oct 21, 2021
1 parent 0989593 commit 6334413
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 55 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ nfpms:
type: symlink
empty_folders:
- /usr/lib/compose-generator/templates
- /usr/lib/compose-generator/log
release:
name_template: v{{ .Tag }}
prerelease: auto
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

---

## Documentation
**Please visit the documentation on [compose-generator.com](https://www.compose-generator.com).**

If Compose Generator helps you, please consider a GitHub star star! ⭐

### Install Compose Generator
To install Compose Generator on your system, please visit the [installation section](https://www.compose-generator.com/install/linux/) in the documentation. Compose Generator is available for the latest versions of Alpine, CentOS, Debian, Fedora, Raspbian, Ubuntu and Windows. If you want to install Compose Generator manually by downloading a package file, please take a look at the table below.

Expand Down Expand Up @@ -55,7 +56,7 @@ There are downloadable packages available for all supported platforms:
| **Windows Portable (zip)** | [download](https://github.com/compose-generator/compose-generator/releases/latest/download/compose-generator_windows_amd64.zip) | [download](https://github.com/compose-generator/compose-generator/releases/latest/download/compose-generator_windows_386.zip) | - | - | - | - |

## Contribute by providing predefined templates
If you miss a predefined template and you want to create one for the public, please read the [instructions to create one](./predefined-services/README.md). Fork the repository, create the template and open a pr to the latest `release/v...` branch.
If you miss a predefined template and you want to create one for the public, please read the [instructions to create a template](./predefined-services/README.md). Fork the repository, create the template and open a pr against the latest `release/v...` branch.
The community is thankful for every predefined template!

## Contribute otherwise to the project
Expand Down
11 changes: 7 additions & 4 deletions predefined-services/backend/aspnet/backend-aspnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
# Builder
FROM mcr.microsoft.com/dotnet/sdk:${{DOTNET_VERSION}} AS builder
WORKDIR /app

COPY *.csproj ./
Expand All @@ -7,8 +8,10 @@ RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:3.1

# Minimalistic image
FROM mcr.microsoft.com/dotnet/aspnet:${{ASPNET_VERSION}}
WORKDIR /app
COPY --from=build-env /app/out .
COPY --from=builder /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "backend.dll"]
ENTRYPOINT [ "dotnet", "${{ASPNET_APP_NAME}}.dll" ]
17 changes: 14 additions & 3 deletions predefined-services/backend/aspnet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"preselected": "false",
"proxied": true,
"demoAppInitCmd": [
"cd ${{ASPNET_SOURCE_DIRECTORY}}",
"dotnet new webapp"
"dotnet new webapp --force --name ${{ASPNET_APP_NAME}}",
"mv ./${{ASPNET_APP_NAME}}/* ./${{ASPNET_SOURCE_DIRECTORY}}/",
"rm -rf ./${{ASPNET_APP_NAME}}"
],
"files": [
{
Expand All @@ -14,6 +15,10 @@
{
"path": "README.md",
"type": "docs"
},
{
"path": "${{ASPNET_SOURCE_DIRECTORY}}/Dockerfile",
"type": "config"
}
],
"questions": [
Expand All @@ -27,7 +32,13 @@
{
"text": "Which .NET version do you want to use?",
"type": 2,
"defaultValue": "3.2.3",
"defaultValue": "5.0",
"variable": "DOTNET_VERSION"
},
{
"text": "Which ASP.NET version do you want to use?",
"type": 2,
"defaultValue": "3.1",
"variable": "ASPNET_VERSION"
},
{
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/backend/django/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{
"text": "Which Django version do you want to use?",
"type": 2,
"defaultValue": "3.2.7",
"defaultValue": "3.2.8",
"variable": "DJANGO_VERSION"
},
{
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/backend/nexus/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which version of Nexus do you want to use?",
"type": 2,
"defaultValue": "3.34.0",
"defaultValue": "3.35.0",
"variable": "NEXUS_VERSION"
}
],
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/backend/node/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
"text": "Which version of Node do you want to use?",
"type": 2,
"defaultValue": "16.9",
"defaultValue": "17.0",
"variable": "NODE_VERSION"
}
],
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/backend/prometheus/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which version of Prometheus do you want to use?",
"type": 2,
"defaultValue": "2.30.0",
"defaultValue": "2.30.3",
"variable": "PROMETHEUS_VERSION"
}
],
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/database/elasticsearch/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which Elasticsearch version do you want to use?",
"type": 2,
"defaultValue": "7.14.1",
"defaultValue": "7.14.2",
"variable": "ELASTICSEARCH_VERSION",
"advanced": true
}
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/database/faunadb/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{
"text": "Which FaunaDB version do you want to use?",
"type": 2,
"defaultValue": "4.2.0",
"defaultValue": "4.3.0",
"variable": "FAUNADB_VERSION",
"advanced": true
}
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/database/postgres/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{
"text": "Which Postgres version do you want to use?",
"type": 2,
"defaultValue": "13.4",
"defaultValue": "14.0",
"variable": "POSTGRES_VERSION",
"advanced": true
}
Expand Down
Empty file modified predefined-services/database/singlestore/README.md
100644 → 100755
Empty file.
Empty file modified predefined-services/database/singlestore/config.json
100644 → 100755
Empty file.
Empty file modified predefined-services/database/singlestore/environment.env
100644 → 100755
Empty file.
Empty file modified predefined-services/database/singlestore/service.yml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion predefined-services/frontend/bitbucket/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{
"text": "Which version of BitBucket do you want to use?",
"type": 2,
"defaultValue": "7.16",
"defaultValue": "7.17",
"variable": "BITBUCKET_VERSION"
}
],
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/gitlab/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{
"text": "Which version of GitLab do you want to use?",
"type": 2,
"defaultValue": "14.3.0",
"defaultValue": "14.3.3",
"variable": "GITLAB_VERSION",
"advanced": true
}
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/grafana/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which version of Grafana do you want to use?",
"type": 2,
"defaultValue": "8.1.5",
"defaultValue": "8.2.1",
"variable": "GRAFANA_VERSION",
"advanced": true
}
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/jira/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"text": "Which version of Jira do you want to use?",
"type": 2,
"defaultValue": "8.19",
"defaultValue": "8.20",
"variable": "JIRA_VERSION",
"advanced": true
},
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/nextcloud/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"text": "Which version of Nextcloud do you want to use?",
"type": 2,
"defaultValue": "22.1",
"defaultValue": "22.2",
"variable": "NEXTCLOUD_VERSION"
},
{
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/openproject/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"text": "Which version of OpenProject do you want to use?",
"type": 2,
"defaultValue": "11",
"defaultValue": "11.4",
"variable": "OPENPROJECT_VERSION"
},
{
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/uptime-kuma/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which version of Uptime Kuma do you want to use?",
"type": 2,
"defaultValue": "1.6.3",
"defaultValue": "1.9.1",
"variable": "UPTIME_KUMA_VERSION"
}
],
Expand Down
2 changes: 1 addition & 1 deletion predefined-services/frontend/youtrack/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"text": "Which version of YouTack do you want to use (latest not available)?",
"type": 2,
"defaultValue": "2021.3.26792",
"defaultValue": "2021.3.30245",
"variable": "YOUTRACK_VERSION",
"advanced": true
}
Expand Down
15 changes: 6 additions & 9 deletions src/util/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ func GetDockerVersion() string {

// GetCustomTemplatesPath returns the path to the custom templates directory
func GetCustomTemplatesPath() string {
templatesPath := "/usr/lib/compose-generator/templates"
if fileExists(templatesPath) {
return templatesPath // Linux
if fileExists("/usr/bin/compose-generator") {
return "/usr/lib/compose-generator/templates" // Linux
}
filename, err := executable()
if err != nil {
Expand All @@ -71,9 +70,8 @@ func GetCustomTemplatesPath() string {

// GetPredefinedServicesPath returns the path to the predefined services directory
func GetPredefinedServicesPath() string {
psPathLinux := "/usr/lib/compose-generator/predefined-services"
if fileExists(psPathLinux) {
return psPathLinux // Linux
if fileExists("/usr/bin/compose-generator") {
return "/usr/lib/compose-generator/predefined-services" // Linux
}
filename, err := executable()
if err != nil {
Expand Down Expand Up @@ -122,9 +120,8 @@ func IsDockerRunning() bool {
// --------------------------------------------------------------- Private functions ---------------------------------------------------------------

func getLogfilesPath() string {
logPathLinux := "/usr/lib/compose-generator/log"
if fileExists(logPathLinux) {
return logPathLinux // Linux
if fileExists("/usr/bin/compose-generator") {
return "/usr/lib/compose-generator/log" // Linux
}
filename, err := executable()
if err != nil {
Expand Down
29 changes: 10 additions & 19 deletions src/util/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,27 @@ func TestIsCIEnvironment2(t *testing.T) {

func TestGetCustomTemplatesPath1(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/templates"
// Mock functions
fileExists = func(path string) bool {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return true
}
// Execute test
result := GetCustomTemplatesPath()
// Assert
assert.Equal(t, pathLinux, result)
assert.Equal(t, "/usr/lib/compose-generator/templates", result)
}

func TestGetCustomTemplatesPath2(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/templates"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/templates"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
// Mock functions
fileExistsCallCount := 0
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand All @@ -115,15 +113,14 @@ func TestGetCustomTemplatesPath2(t *testing.T) {

func TestGetCustomTemplatesPath3(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/templates"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/templates"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
// Mock functions
fileExistsCallCount := 0
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand All @@ -147,7 +144,6 @@ func TestGetCustomTemplatesPath3(t *testing.T) {

func TestGetCustomTemplatesPath4(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/templates"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/templates"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
pathDev := "../templates"
Expand All @@ -156,7 +152,7 @@ func TestGetCustomTemplatesPath4(t *testing.T) {
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand Down Expand Up @@ -206,30 +202,27 @@ func TestGetUsername2(t *testing.T) {
// ----------------------------------------------------------- GetPredefinedServicesPath -----------------------------------------------------------

func TestGetPredefinedServicesPath1(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/predefined-services"
// Mock functions
fileExists = func(path string) bool {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return true
}
// Execute test
result := GetPredefinedServicesPath()
// Assert
assert.Equal(t, pathLinux, result)
assert.Equal(t, "/usr/lib/compose-generator/predefined-services", result)
}

func TestGetPredefinedServicesPath2(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/predefined-services"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/predefined-services"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
// Mock functions
fileExistsCallCount := 0
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand All @@ -249,15 +242,14 @@ func TestGetPredefinedServicesPath2(t *testing.T) {

func TestGetPredefinedServicesPath3(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/predefined-services"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/predefined-services"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
// Mock functions
fileExistsCallCount := 0
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand All @@ -281,7 +273,6 @@ func TestGetPredefinedServicesPath3(t *testing.T) {

func TestGetPredefinedServicesPath4(t *testing.T) {
// Test data
pathLinux := "/usr/lib/compose-generator/predefined-services"
pathWindowsDocker := "/usr/bin/compose-generator/test/path/predefined-services"
pathExecutable := "/usr/bin/compose-generator/test/path/dir"
pathDev := "../predefined-services"
Expand All @@ -290,7 +281,7 @@ func TestGetPredefinedServicesPath4(t *testing.T) {
fileExists = func(path string) bool {
fileExistsCallCount++
if fileExistsCallCount == 1 {
assert.Equal(t, pathLinux, path)
assert.Equal(t, "/usr/bin/compose-generator", path)
return false
}
assert.Equal(t, pathWindowsDocker, path)
Expand Down

0 comments on commit 6334413

Please sign in to comment.