mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
lidl dockerize
This commit is contained in:
parent
a7b7ea816a
commit
8c0b7b322f
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -23,4 +23,6 @@ NourybotApi
|
|||
NourybotApi.out
|
||||
nourybot-api
|
||||
Nourybot-Web
|
||||
nourybot-web
|
||||
nourybot-web
|
||||
nourybot
|
||||
|
||||
|
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Start from golang base image
|
||||
FROM golang:alpine
|
||||
|
||||
RUN apk add --no-cache make
|
||||
# Setup folders
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the source from the current directory to the working Directory inside the container
|
||||
COPY . .
|
||||
COPY .env .
|
||||
|
||||
# Download all the dependencies
|
||||
RUN go get -d -v ./...
|
||||
|
||||
# Build the Go app
|
||||
RUN go build ./cmd/nourybot
|
||||
|
||||
# Run the executable
|
||||
CMD [ "./nourybot", "env='prod'" ]
|
6
Makefile
6
Makefile
|
@ -21,6 +21,12 @@ jqprod:
|
|||
mv cmd/nourybot/${BINARY_NAME} ./bin/${BINARY_NAME}
|
||||
./bin/${BINARY_NAME} -env="prod" | jq
|
||||
|
||||
build:
|
||||
cd cmd/nourybot && go build -o ${BINARY_NAME}
|
||||
mv cmd/nourybot/${BINARY_NAME} ./bin/${BINARY_NAME}
|
||||
|
||||
run:
|
||||
./bin/${BINARY_NAME} -env="prod"
|
||||
|
||||
prod:
|
||||
cd cmd/nourybot && go build -o ${BINARY_NAME}
|
||||
|
|
|
@ -80,7 +80,7 @@ func main() {
|
|||
|
||||
switch envFlag {
|
||||
case "dev":
|
||||
cfg.db.dsn = os.Getenv("LOCAL_DSN")
|
||||
cfg.db.dsn = os.Getenv("REMOTE_DSN")
|
||||
case "prod":
|
||||
cfg.db.dsn = os.Getenv("REMOTE_DSN")
|
||||
}
|
||||
|
|
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
version: "3.7"
|
||||
services:
|
||||
database:
|
||||
image: postgres
|
||||
restart: always
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "127.0.0.1:55432:5432"
|
||||
volumes:
|
||||
- data:/var/lib/postgresql/data
|
||||
nourybot:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file: .env
|
||||
depends_on:
|
||||
- database
|
||||
volumes:
|
||||
data:
|
Loading…
Reference in a new issue