lidl dockerize

This commit is contained in:
lyx0 2023-12-03 20:50:38 +01:00
parent a7b7ea816a
commit 8c0b7b322f
5 changed files with 50 additions and 2 deletions

4
.gitignore vendored
View file

@ -23,4 +23,6 @@ NourybotApi
NourybotApi.out
nourybot-api
Nourybot-Web
nourybot-web
nourybot-web
nourybot

20
Dockerfile Normal file
View 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'" ]

View file

@ -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}

View file

@ -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
View 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: