Dockerize auth service

This commit is contained in:
vinchent 2024-08-28 14:24:16 +02:00
parent 3dba9b23dc
commit 27cab1505c
4 changed files with 54 additions and 7 deletions

3
.gitignore vendored
View File

@ -6,5 +6,4 @@ cred.txt
dist/ dist/
.air.toml .air.toml
tmp/ tmp/
broker-service/brokerApp */*App
front-end/frontApp

View File

@ -0,0 +1,8 @@
FROM alpine:latest
RUN mkdir /app
COPY authApp /app
CMD ["/app/authApp"]

View File

@ -1,24 +1,25 @@
FRONT_END_BINARY=frontApp FRONT_END_BINARY=frontApp
BROKER_BINARY=brokerApp BROKER_BINARY=brokerApp
AUTH_BINARY=authApp
## up: starts all containers in the background without forcing build ## up: starts all containers in the background without forcing build
up: up:
@echo "Starting Docker images..." @echo "Starting Docker images..."
sudo docker compose up -d docker compose up -d
@echo "Docker images started!" @echo "Docker images started!"
## up_build: stops docker-compose (if running), builds all projects and starts docker compose ## up_build: stops docker-compose (if running), builds all projects and starts docker compose
up_build: build_broker up_build: build_broker build_auth
@echo "Stopping docker images (if running...)" @echo "Stopping docker images (if running...)"
sudo docker compose down docker compose down
@echo "Building (when required) and starting docker images..." @echo "Building (when required) and starting docker images..."
sudo docker compose up --build -d docker compose up --build -d
@echo "Docker images built and started!" @echo "Docker images built and started!"
## down: stop docker compose ## down: stop docker compose
down: down:
@echo "Stopping docker compose..." @echo "Stopping docker compose..."
sudo docker compose down docker compose down
@echo "Done!" @echo "Done!"
## build_broker: builds the broker binary as a linux executable ## build_broker: builds the broker binary as a linux executable
@ -27,6 +28,12 @@ build_broker:
cd ../broker-service && env GOOS=linux CGO_ENABLED=0 go build -o ${BROKER_BINARY} ./cmd/api cd ../broker-service && env GOOS=linux CGO_ENABLED=0 go build -o ${BROKER_BINARY} ./cmd/api
@echo "Done!" @echo "Done!"
## build_auth: builds the auth binary as a linux executable
build_auth:
@echo "Building auth binary..."
cd ../authentication-service && env GOOS=linux CGO_ENABLED=0 go build -o ${AUTH_BINARY} ./cmd/api
@echo "Done!"
## build_front: builds the frone end binary ## build_front: builds the frone end binary
build_front: build_front:
@echo "Building front end binary..." @echo "Building front end binary..."

View File

@ -9,3 +9,36 @@ services:
deploy: deploy:
mode: replicated mode: replicated
replicas: 1 replicas: 1
authentication-service:
build:
context: ./../authentication-service/
dockerfile: ./../authentication-service/authentication-service.dockerfile
ports:
- "8081:4000"
deploy:
mode: replicated
replicas: 1
environment:
DSN: "host=postgres port=5432 user=postgres password=password dbname=users timezone=UTC connect_timeout=5"
postgres:
image: postgres
ports:
- "5432:5432"
restart: always
deploy:
mode: replicated
replicas: 1
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: users
volumes:
- ./db-data/postgres:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- 8090:8080