Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Улучшения в докер-обвязке бота #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.idea
.env
.env.*
.cache/
vendor/

!.env.sample
config/config.yml
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM golang:1.13-alpine AS pososyamba

ENV GOPATH /application/vendor
ENV HOME /application

WORKDIR /application

RUN apk update && apk upgrade && \
Expand All @@ -11,7 +14,3 @@ COPY go.sum .
RUN go mod download

COPY . .

RUN go build ./cmd/pososyamba_bot/main.go

CMD [ "./main" ]
32 changes: 27 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
run_development:
docker-compose run --rm bot bash
UID=$(shell id -u)
USRENAME=`id -un`
USER_PARAM=--user $(shell id -u):$(shell id -g)
APP_VOLUME_PARAM=-v `pwd`/.:/application
APP_PORT_PARAM=-p 80:3000/tcp
CONTAINER_NAME=thesunwave/pososyamba:latest
DOCKER_RUN=docker run -it ${USER_PARAM} ${APP_VOLUME_PARAM} ${APP_PORT_PARAM} ${CONTAINER_NAME}
DOCKER_COMPOSE_RUN=docker-compose run ${USER_PARAM} bot

build: Dockerfile
build_prod: Dockerfile
docker build --rm -f "Dockerfile" -t thesunwave/pososyamba:latest .

run:
docker run --env-file .env.development pososyamba:latest
run_prod: build_image
${DOCKER_RUN}--env-file .env.development

clean:
rm -f ./main

build_devel: clean
${DOCKER_COMPOSE_RUN} /bin/sh -c "go build -work /application/cmd/pososyamba_bot/main.go"
chmod a+x ./main

up: build_devel
docker-compose up

down:
docker-compose down

sh:
${DOCKER_COMPOSE_RUN} /bin/bash -l
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build:
context: .
dockerfile: Dockerfile.development
command: sh -c "go build /application/cmd/pososyamba_bot/main.go && /application/main"
command: /application/main
depends_on:
- redis
env_file:
Expand Down