github.com/jchauncey/draft@v0.3.0/pkg/draft/defaultpacks/java.go (about)

     1  package defaultpacks
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"github.com/Azure/draft/pkg/draft/pack"
     7  )
     8  
     9  const javaValues = `# Default values for Java.
    10  # This is a YAML-formatted file.
    11  # Declare variables to be passed into your templates.
    12  replicaCount: 2
    13  image:
    14    registry: docker.io
    15    org: library
    16    name: maven
    17    tag: onbuild
    18    pullPolicy: IfNotPresent
    19  service:
    20    name: java
    21    type: ClusterIP
    22    externalPort: 80
    23    internalPort: 4567
    24  resources:
    25    limits:
    26      cpu: 100m
    27      memory: 128Mi
    28    requests:
    29      cpu: 100m
    30      memory: 128Mi
    31  `
    32  
    33  const javaDetect = `#!/usr/bin/env bash
    34  # bin/use <build-dir>
    35  
    36  if [ -f $1/pom.xml ]; then
    37     echo "Java" && exit 0
    38  else
    39    echo "no" && exit 1
    40  fi
    41  `
    42  
    43  const javaDockerfile = `FROM maven:onbuild
    44  EXPOSE 4567
    45  ENTRYPOINT java
    46  CMD ["-jar", "target/helloworld-jar-with-dependencies.jar"]
    47  `
    48  
    49  // JavaFiles returns all of the files needed for the Java default pack
    50  // Paths are relative to the pack root
    51  func JavaFiles() []*pack.File {
    52  	return []*pack.File{
    53  		{
    54  			// values.yaml
    55  			Path:    filepath.Join(pack.ChartDir, pack.ValuesfileName),
    56  			Content: []byte(javaValues),
    57  			Perm:    0644,
    58  		},
    59  		{
    60  			// .helmignore
    61  			Path:    filepath.Join(pack.ChartDir, pack.IgnorefileName),
    62  			Content: []byte(commonIgnore),
    63  			Perm:    0644,
    64  		},
    65  		{
    66  			// deployment.yaml
    67  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.DeploymentName),
    68  			Content: []byte(commonDeployment),
    69  			Perm:    0644,
    70  		},
    71  		{
    72  			// service.yaml
    73  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.ServiceName),
    74  			Content: []byte(commonService),
    75  			Perm:    0644,
    76  		},
    77  		{
    78  			// ingress.yaml
    79  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.IngressName),
    80  			Content: []byte(commonIngress),
    81  			Perm:    0644,
    82  		},
    83  		{
    84  			// NOTES.txt
    85  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.NotesName),
    86  			Content: []byte(commonNotes),
    87  			Perm:    0644,
    88  		},
    89  		{
    90  			// _helpers.tpl
    91  			Path:    filepath.Join(pack.ChartDir, pack.TemplatesDir, pack.HelpersName),
    92  			Content: []byte(commonHelpers),
    93  			Perm:    0644,
    94  		},
    95  		{
    96  			// detect
    97  			Path:    filepath.Join(pack.DetectName),
    98  			Content: []byte(javaDetect),
    99  			Perm:    0755,
   100  		},
   101  		{
   102  			// NOTICE
   103  			Path:    filepath.Join(pack.HerokuLicenseName),
   104  			Content: []byte(commonHerokuLicense),
   105  			Perm:    0644,
   106  		},
   107  		{
   108  			// Dockerfile
   109  			Path:    filepath.Join(pack.DockerfileName),
   110  			Content: []byte(javaDockerfile),
   111  			Perm:    0644,
   112  		},
   113  		{
   114  			// .dockerignore
   115  			Path:    filepath.Join(pack.DockerignoreName),
   116  			Content: []byte(commonDockerignore),
   117  			Perm:    0644,
   118  		},
   119  	}
   120  }