Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #136 from ZupIT/feature/updateDockerfiles
Browse files Browse the repository at this point in the history
[FEATURE] update templates
  • Loading branch information
victor-schumacher authored Jun 2, 2020
2 parents 1cadf09 + ecbc1f0 commit 2f9ccb5
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pkg/cmd/create_formula.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (c createFormulaCmd) runPrompt() CommandRunnerFunc {
return err
}

fmt.Printf("Formula in %s successfully created!\n", lang)
fmt.Printf("Your formula is in %s", f.FormPath)
fmt.Printf("%s formula successfully created!\n", lang)
fmt.Printf("Formula path is %s \n", f.FormPath)

return nil
}
Expand All @@ -115,8 +115,8 @@ func (c createFormulaCmd) runStdin() CommandRunnerFunc {
return err
}

fmt.Printf("Formula in %s successfully created!\n", cf.Lang)
fmt.Printf("Your formula is in %s\n", f.FormPath)
fmt.Printf("%s formula successfully created!\n", cf.Lang)
fmt.Printf("Formula path is %s \n", f.FormPath)

return nil
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/formula/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ZupIT/ritchie-cli/pkg/api"
"github.com/ZupIT/ritchie-cli/pkg/file/fileutil"
"github.com/ZupIT/ritchie-cli/pkg/formula/tpl/tpl_go"
"github.com/ZupIT/ritchie-cli/pkg/formula/tpl/tpl_shell"
)

var ErrMakefileNotFound = errors.New("makefile not found")
Expand Down Expand Up @@ -278,6 +279,9 @@ func createGenericFiles(srcDir, pkg, dir string, l Lang) error {
if err != nil {
return err
}
if err := createUmask(srcDir); err != nil {
return err
}

return nil
}
Expand All @@ -304,6 +308,11 @@ func createDockerfile(dir, tpl string) error {
return fileutil.WriteFile(fmt.Sprintf("%s/Dockerfile", dir), []byte(tpl))
}

func createUmask(dir string) error {
uMaskFile := fmt.Sprintf("%s/set_umask.sh", dir)
return fileutil.WriteFile(uMaskFile, []byte(tpl_shell.Umask))
}

func createGoModFile(dir, pkg string) error {
tplFile := tpl_go.GoMod
tplFile = strings.ReplaceAll(tplFile, nameModule, pkg)
Expand Down
20 changes: 14 additions & 6 deletions pkg/formula/tpl/tpl_go/tpl_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,22 @@ test:

Dockerfile = `
FROM golang:alpine AS builder
WORKDIR /app/
COPY . .
ADD . /app
WORKDIR /app
RUN go build -o main -v main.go
FROM alpine:latest
WORKDIR /app/
COPY --from=builder app/main .
ENTRYPOINT ["./main"]`
FROM alpine:latest
COPY --from=builder /app/main main
COPY --from=builder /app/set_umask.sh set_umask.sh
RUN chmod +x main
RUN chmod +x set_umask.sh
WORKDIR /app
ENTRYPOINT ["/set_umask.sh"]
CMD ["/main"]`

MakefileMain = `#Makefiles
{{formName}}={{formPath}}
Expand Down
6 changes: 5 additions & 1 deletion pkg/formula/tpl/tpl_java/tpl_java.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ RUN apk add openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"
ENTRYPOINT java -jar Main.jar`
RUN javac Main.java
RUN chmod +x set_umask.sh
ENTRYPOINT ["/app/set_umask.sh"]
CMD ["java Main"]`

Run = `#!/bin/sh
java -jar Main.jar`
Expand Down
4 changes: 3 additions & 1 deletion pkg/formula/tpl/tpl_node/tpl_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ WORKDIR /app
COPY . .
ENTRYPOINT node index.js`
RUN chmod +x set_umask.sh
ENTRYPOINT ["/app/set_umask.sh"]
CMD ["node index.js"]`

Run = `#!/bin/sh
node index.js`
Expand Down
5 changes: 4 additions & 1 deletion pkg/formula/tpl/tpl_python/tpl_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ WORKDIR /app
COPY . .
ENTRYPOINT python3 main.py`
RUN chmod +x set_umask.sh
ENTRYPOINT ["/app/set_umask.sh"]
CMD ["python3 main.py"]`

File = `#!/usr/bin/python3
import time
Expand Down
8 changes: 7 additions & 1 deletion pkg/formula/tpl/tpl_shell/tpl_shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ WORKDIR /app
COPY . .
RUN chmod +x main.sh
RUN chmod +x set_umask.sh
ENTRYPOINT /app/main.sh`
ENTRYPOINT ["/app/set_umask.sh"]
CMD ["./main.sh"]`

Umask = `#!/bin/sh
umask 0011
$1`

File = `#!/bin/sh
run() {
Expand Down

0 comments on commit 2f9ccb5

Please sign in to comment.