-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Server): Credential in env and docker compose for server
- Loading branch information
Showing
12 changed files
with
66 additions
and
36 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,22 @@ | ||
FROM golang:1.23.3-alpine as builder | ||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN go mod tidy | ||
RUN go mod download | ||
RUN go get -u github.com/swaggo/swag | ||
RUN go get -u github.com/gin-gonic/gin | ||
RUN go build -o main . | ||
|
||
|
||
FROM debian:bullseye-slim | ||
|
||
WORKDIR /app | ||
COPY --from=builder /app/main . | ||
COPY --from=builder /app/.env . | ||
COPY --from=builder /app/config.json . | ||
|
||
RUN chmod +x /app/main | ||
|
||
EXPOSE 8080 | ||
CMD ["./main"] |
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,19 +1,11 @@ | ||
{ | ||
"app_name": "AREA", | ||
"port": 8081, | ||
"port": 8080, | ||
"gin_mode": "debug", | ||
"secret_key": "your-secure-secret-key", | ||
"cors": true, | ||
"db": { | ||
"host": "127.0.1", | ||
"port": 3306, | ||
"name": "area", | ||
"user": "root", | ||
"password": "root" | ||
}, | ||
"swagger": true, | ||
"cors_origins": [ | ||
"http://localhost:3000", | ||
"http://localhost:8081", | ||
"http://example.com" | ||
] | ||
} |
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 |
---|---|---|
|
@@ -16,8 +16,8 @@ const docTemplate = `{ | |
"email": "[email protected]" | ||
}, | ||
"license": { | ||
"name": "Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
"name": "GPL-3.0", | ||
"url": "https://www.gnu.org/licenses/gpl-3.0.en.html#license-text" | ||
}, | ||
"version": "{{.Version}}" | ||
}, | ||
|
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 |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
"email": "[email protected]" | ||
}, | ||
"license": { | ||
"name": "Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
"name": "GPL-3.0", | ||
"url": "https://www.gnu.org/licenses/gpl-3.0.en.html#license-text" | ||
}, | ||
"version": "1.0" | ||
}, | ||
|
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
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
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
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 @@ | ||
package utils | ||
|
||
import ( | ||
"encoding/base64" | ||
"golang.org/x/crypto/argon2" | ||
) | ||
|
||
func HashPassword(password string) string { | ||
salt := []byte("randomSalt") // Ideally, generate a unique salt per user | ||
hash := argon2.IDKey([]byte(password), salt, 1, 64*1024, 4, 32) | ||
return base64.RawStdEncoding.EncodeToString(hash) | ||
} |
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
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 |
---|---|---|
|
@@ -20,8 +20,8 @@ import ( | |
// @contact.url http://www.swagger.io/support | ||
// @contact.email [email protected] | ||
|
||
// @license.name Apache 2.0 | ||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html | ||
// @license.name GPL-3.0 | ||
// @license.url https://www.gnu.org/licenses/gpl-3.0.en.html#license-text | ||
|
||
// @host localhost:8080 | ||
// @BasePath / | ||
|
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,7 @@ | ||
#! /bin/bash | ||
|
||
# Start the server | ||
COMPOSE_FILE=build/docker-compose.yml | ||
ENV_FILE=.env | ||
|
||
docker-compose --env-file $ENV_FILE -f $COMPOSE_FILE -p server up --build -d |
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,7 @@ | ||
#! /bin/bash | ||
|
||
# Stop the server | ||
COMPOSE_FILE=build/docker-compose.yml | ||
ENV_FILE=.env | ||
|
||
docker-compose --env-file $ENV_FILE -f $COMPOSE_FILE down --remove-orphans |