This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build.bat and Dockerfiles (#289)
* Fix build .bat copying files to bin folder Signed-off-by: maurineimirandazup <maurinei.miranda@zup.com.br> * Fix to run with Docker Signed-off-by: maurineimirandazup <maurinei.miranda@zup.com.br> * Fix makefile to copy Dockerfile Signed-off-by: maurineimirandazup <maurinei.miranda@zup.com.br>
- Loading branch information
1 parent
3f4bc09
commit 3280926
Showing
5 changed files
with
114 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM alpine:3.12 | ||
USER root | ||
|
||
RUN mkdir /rit | ||
COPY . /rit | ||
RUN sed -i 's/\r//g' /rit/set_umask.sh | ||
RUN sed -i 's/\r//g' /rit/run.sh | ||
RUN chmod +x /rit/set_umask.sh | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/rit/set_umask.sh"] | ||
CMD ["/rit/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
# Go parameters | ||
BIN_FOLDER=bin | ||
SH=$(BIN_FOLDER)/run.sh | ||
BAT=$(BIN_FOLDER)/run.bat | ||
BIN_NAME=main | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
GOTEST=$(GOCMD) test | ||
CMD_PATH=main.go | ||
BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin | ||
BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) | ||
BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux | ||
BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) | ||
BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows | ||
BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe | ||
|
||
|
||
build: go-build sh-unix bat-windows | ||
|
||
go-build: | ||
cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) | ||
#LINUX | ||
cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) | ||
#MAC | ||
cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) | ||
#WINDOWS 64 | ||
cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) | ||
|
||
cp -r src/files $(BIN_FOLDER)/files | ||
|
||
sh-unix: | ||
echo '#!/bin/sh' > $(SH) | ||
echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) | ||
echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) | ||
echo 'else' >> $(SH) | ||
echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) | ||
echo 'fi' >> $(SH) | ||
chmod +x $(SH) | ||
|
||
bat-windows: | ||
echo '@ECHO OFF' > $(BAT) | ||
echo 'SET mypath=%~dp0' >> $(BAT) | ||
echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) | ||
|
||
test: | ||
$(GOTEST) -short `go list ./... | grep -v vendor/` | ||
# Go parameters | ||
BIN_FOLDER=bin | ||
SH=$(BIN_FOLDER)/run.sh | ||
BAT=$(BIN_FOLDER)/run.bat | ||
BIN_NAME=main | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
GOTEST=$(GOCMD) test | ||
CMD_PATH=main.go | ||
BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin | ||
BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) | ||
BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux | ||
BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) | ||
BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows | ||
BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe | ||
|
||
|
||
build: go-build sh-unix bat-windows docker | ||
|
||
go-build: | ||
cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) | ||
#LINUX | ||
cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) | ||
#MAC | ||
cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) | ||
#WINDOWS 64 | ||
cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) | ||
|
||
cp -r src/files $(BIN_FOLDER)/files | ||
|
||
sh-unix: | ||
echo '#!/bin/sh' > $(SH) | ||
echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) | ||
echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) | ||
echo 'else' >> $(SH) | ||
echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) | ||
echo 'fi' >> $(SH) | ||
chmod +x $(SH) | ||
|
||
bat-windows: | ||
echo '@ECHO OFF' > $(BAT) | ||
echo 'SET mypath=%~dp0' >> $(BAT) | ||
echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) | ||
|
||
test: | ||
$(GOTEST) -short `go list ./... | grep -v vendor/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
:: Go parameters | ||
echo off | ||
SETLOCAL | ||
SET BINARY_NAME=main | ||
SET GOCMD=go | ||
SET GOBUILD=%GOCMD% build | ||
SET CMD_PATH=main.go | ||
SET BIN_FOLDER=..\bin | ||
SET DIST_WIN_DIR=%BIN_FOLDER%\windows | ||
SET DIST_LINUX_DIR=%BIN_FOLDER%\linux | ||
SET BIN_WIN=%BINARY_NAME%.exe | ||
SET BAT_FILE=%BIN_FOLDER%\run.bat | ||
SET SH_FILE=%BIN_FOLDER%\run.sh | ||
|
||
:build | ||
cd src | ||
mkdir %DIST_WIN_DIR% | ||
SET GO111MODULE=on | ||
for /f %%i in ('go list -m') do set MODULE=%%i | ||
CALL :windows | ||
CALL :linux | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
GOTO CP_DOCKER | ||
GOTO DONE | ||
cd .. | ||
|
||
:windows | ||
SET CGO_ENABLED= | ||
SET GOOS=windows | ||
SET GOARCH=amd64 | ||
%GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% | ||
echo @ECHO OFF > %BAT_FILE% | ||
echo SET mypath=%%~dp0 >> %BAT_FILE% | ||
echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% | ||
GOTO DONE | ||
|
||
:linux | ||
SET CGO_ENABLED=0 | ||
SET GOOS=linux | ||
SET GOARCH=amd64 | ||
%GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% | ||
echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% | ||
GOTO DONE | ||
|
||
:CP_DOCKER | ||
copy ..\Dockerfile %BIN_FOLDER% | ||
copy ..\set_umask.sh %BIN_FOLDER% | ||
GOTO DONE | ||
:DONE | ||
:: Go parameters | ||
echo off | ||
SETLOCAL | ||
SET BINARY_NAME=main | ||
SET GOCMD=go | ||
SET GOBUILD=%GOCMD% build | ||
SET CMD_PATH=main.go | ||
SET BIN_FOLDER=..\bin | ||
SET DIST_WIN_DIR=%BIN_FOLDER%\windows | ||
SET DIST_LINUX_DIR=%BIN_FOLDER%\linux | ||
SET BIN_WIN=%BINARY_NAME%.exe | ||
SET BAT_FILE=%BIN_FOLDER%\run.bat | ||
SET SH_FILE=%BIN_FOLDER%\run.sh | ||
|
||
:build | ||
cd src | ||
xcopy /e/h/i files %BIN_FOLDER%\files | ||
mkdir %DIST_WIN_DIR% | ||
SET GO111MODULE=on | ||
for /f %%i in ('go list -m') do set MODULE=%%i | ||
CALL :windows | ||
CALL :linux | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
GOTO CP_DOCKER | ||
GOTO DONE | ||
cd .. | ||
|
||
:windows | ||
SET CGO_ENABLED= | ||
SET GOOS=windows | ||
SET GOARCH=amd64 | ||
%GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% | ||
echo @ECHO OFF > %BAT_FILE% | ||
echo SET mypath=%%~dp0 >> %BAT_FILE% | ||
echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% | ||
GOTO DONE | ||
|
||
:linux | ||
SET CGO_ENABLED=0 | ||
SET GOOS=linux | ||
SET GOARCH=amd64 | ||
%GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% | ||
echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% | ||
GOTO DONE | ||
|
||
:CP_DOCKER | ||
copy ..\Dockerfile %BIN_FOLDER% | ||
copy ..\set_umask.sh %BIN_FOLDER% | ||
GOTO DONE | ||
:DONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
umask 0011 | ||
$1 |
Empty file.