Skip to content
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-asse
COPY ./git-ask-pass.sh /git-ask-pass.sh
RUN chmod +x /git-ask-pass.sh

RUN useradd -ms /bin/bash devtron
RUN chown -R devtron:devtron ./devtron
RUN chown -R devtron:devtron ./git-ask-pass.sh
RUN chown -R devtron:devtron ./auth_model.conf
RUN chown -R devtron:devtron ./scripts

USER devtron

CMD ["./devtron"]


Expand All @@ -37,4 +45,4 @@ CMD ["./devtron"]
#COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts
#COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON

#CMD ["./devtron-ea"]
#CMD ["./devtron-ea"]
9 changes: 8 additions & 1 deletion DockerfileEA
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON

CMD ["./devtron-ea"]
RUN useradd -ms /bin/bash devtron
RUN chown -R devtron:devtron ./devtron-ea
RUN chown -R devtron:devtron ./auth_model.conf
RUN chown -R devtron:devtron ./scripts

USER devtron

CMD ["./devtron-ea"]
6 changes: 4 additions & 2 deletions pkg/pipeline/CdHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,13 @@ func (impl *CdHandlerImpl) DownloadCdWorkflowArtifacts(pipelineId int, buildId i
CredentialFileJsonData: impl.ciConfig.BlobStorageGcpCredentialJson,
}
key := fmt.Sprintf("%s/"+impl.cdConfig.CdArtifactLocationFormat, impl.cdConfig.DefaultArtifactKeyPrefix, wfr.CdWorkflow.Id, wfr.Id)
baseLogLocationPathConfig := util3.GetBaseLogLocationPath(impl.Logger)
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
destinationKey := baseLogLocationPathConfig + item
request := &blob_storage.BlobStorageRequest{
StorageType: impl.ciConfig.CloudProvider,
SourceKey: key,
DestinationKey: item,
DestinationKey: destinationKey,
AzureBlobBaseConfig: azureBlobBaseConfig,
AwsS3BaseConfig: awsS3BaseConfig,
GcpBlobBaseConfig: gcpBlobBaseConfig,
Expand All @@ -754,7 +756,7 @@ func (impl *CdHandlerImpl) DownloadCdWorkflowArtifacts(pipelineId int, buildId i
return nil, errors.New("failed to download resource")
}

file, err := os.Open(item)
file, err := os.Open(destinationKey)
if err != nil {
impl.Logger.Errorw("unable to open file", "file", item, "err", err)
return nil, errors.New("unable to open file")
Expand Down
7 changes: 5 additions & 2 deletions pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/bean"
"github.com/devtron-labs/devtron/pkg/user"
util3 "github.com/devtron-labs/devtron/util"
util2 "github.com/devtron-labs/devtron/util/event"
"github.com/go-pg/pg"
"go.uber.org/zap"
Expand Down Expand Up @@ -626,11 +627,13 @@ func (impl *CiHandlerImpl) DownloadCiWorkflowArtifacts(pipelineId int, buildId i

key := fmt.Sprintf("%s/"+impl.ciConfig.CiArtifactLocationFormat, impl.ciConfig.DefaultArtifactKeyPrefix, ciWorkflow.Id, ciWorkflow.Id)

baseLogLocationPathConfig := util3.GetBaseLogLocationPath(impl.Logger)
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
destinationKey := baseLogLocationPathConfig + item
request := &blob_storage.BlobStorageRequest{
StorageType: impl.ciConfig.CloudProvider,
SourceKey: key,
DestinationKey: item,
DestinationKey: baseLogLocationPathConfig + item,
AzureBlobBaseConfig: azureBlobConfig,
AwsS3BaseConfig: awsS3BaseConfig,
GcpBlobBaseConfig: gcpBlobBaseConfig,
Expand All @@ -641,7 +644,7 @@ func (impl *CiHandlerImpl) DownloadCiWorkflowArtifacts(pipelineId int, buildId i
return nil, errors.New("failed to download resource")
}

file, err := os.Open(item)
file, err := os.Open(destinationKey)
if err != nil {
impl.Logger.Errorw("unable to open file", "file", item, "err", err)
return nil, errors.New("unable to open file")
Expand Down
5 changes: 3 additions & 2 deletions pkg/pipeline/CiLogService.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
blob_storage "github.com/devtron-labs/common-lib/blob-storage"
"github.com/devtron-labs/devtron/internal/util"
util1 "github.com/devtron-labs/devtron/util"
"go.uber.org/zap"
"io"
v12 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -115,8 +116,8 @@ func (impl *CiLogServiceImpl) FetchRunningWorkflowLogs(ciLogRequest BuildLogRequ
}

func (impl *CiLogServiceImpl) FetchLogs(logRequest BuildLogRequest) (*os.File, func() error, error) {

tempFile := logRequest.PodName + ".log"
baseLogLocationPathConfig := util1.GetBaseLogLocationPath(impl.logger)
tempFile := baseLogLocationPathConfig + logRequest.PodName + ".log"
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
request := &blob_storage.BlobStorageRequest{
StorageType: logRequest.CloudProvider,
Expand Down
14 changes: 14 additions & 0 deletions util/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"compress/gzip"
"encoding/json"
"fmt"
"github.com/caarlos0/env"
"github.com/juju/errors"
"io"
"io/ioutil"
Expand Down Expand Up @@ -208,3 +209,16 @@ func InterfaceToMapAdapter(resp interface{}) map[string]interface{} {
}
return dat
}

type BaseLogLocationConfig struct {
BaseLogLocationPath string `env:"BASE_LOG_LOCATION_PATH" envDefault:"home/devtron/"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in ciConfig and cdConfig and read it from there.

}

func GetBaseLogLocationPath(logger *zap.SugaredLogger) string {
baseLogLocationPathConfig := &BaseLogLocationConfig{}
err := env.Parse(baseLogLocationPathConfig)
if err != nil {
logger.Warnw("error occurred while parsing BaseLogLocationConfig", "err", err)
}
return baseLogLocationPathConfig.BaseLogLocationPath
}