Save state
This commit is contained in:
parent
788c02761d
commit
3ecffa7779
59
.dockerignore
Normal file
59
.dockerignore
Normal file
@ -0,0 +1,59 @@
|
||||
# .dockerignore file for the project
|
||||
|
||||
# Language-specific patterns
|
||||
/vendor/
|
||||
*.test
|
||||
.go-cache
|
||||
|
||||
# Development artifacts
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
dist/
|
||||
build/
|
||||
out/
|
||||
test/
|
||||
tests/
|
||||
*_test.go
|
||||
debug/
|
||||
*.log
|
||||
|
||||
# Version control
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# Environment and secrets
|
||||
.env*
|
||||
*.env
|
||||
*.pem
|
||||
*.key
|
||||
*.crt
|
||||
config.local.*
|
||||
*.local.yml
|
||||
|
||||
# Project-specific patterns
|
||||
docs/
|
||||
*.md
|
||||
README*
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
tmp/
|
||||
temp/
|
||||
*.tmp
|
||||
.local/
|
||||
local/
|
||||
|
||||
# Exclude the following files from being ignored
|
||||
!go.mod
|
||||
!go.sum
|
||||
!cmd/main.go
|
||||
!internal/config/config.go
|
||||
!internal/domain/tasks/task.go
|
||||
!internal/domain/users/user.go
|
||||
!internal/persistance/task_manager.go
|
||||
!internal/persistance/task_repository.go
|
||||
!internal/persistance/user_repository.go
|
||||
!database/init/00-users-init.sql
|
||||
!database/init/01-tasks-init.sql
|
||||
!deployments/task-manager.yaml
|
29
Dockerfile
Normal file
29
Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
# syntax=docker/dockerfile:1.5
|
||||
|
||||
# Build stage
|
||||
ARG GO_VERSION=1.24
|
||||
FROM golang:${GO_VERSION} AS builder
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Cache dependencies and build the application
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=bind,target=. \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /task-manager ./cmd/main.go
|
||||
|
||||
# Final stage
|
||||
FROM scratch AS final
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built binary from the builder stage
|
||||
COPY --from=builder /task-manager ./
|
||||
|
||||
# Expose the application port
|
||||
EXPOSE 8080
|
||||
|
||||
# Set the default command to run the application
|
||||
CMD ["./task-manager"]
|
35
README.md
Normal file
35
README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Running the Project with Docker
|
||||
|
||||
This section provides instructions to build and run the project using Docker.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Docker version 20.10 or later
|
||||
- Docker Compose version 1.29 or later
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `POSTGRES_USER`: Database username (default: `user`)
|
||||
- `POSTGRES_PASSWORD`: Database password (default: `password`)
|
||||
- `POSTGRES_DB`: Database name (default: `appdb`)
|
||||
|
||||
## Build and Run Instructions
|
||||
|
||||
1. Clone the repository and navigate to the project root directory.
|
||||
2. Build and start the services using Docker Compose:
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
3. Access the application at `http://localhost:8080`.
|
||||
|
||||
## Configuration
|
||||
|
||||
- The application binary is built using Go version 1.24.
|
||||
- The database service uses the `postgres:latest` image.
|
||||
|
||||
## Exposed Ports
|
||||
|
||||
- Application: `8080` (mapped to `8080` on the host)
|
||||
- Database: Not exposed to the host
|
||||
|
||||
For further details, refer to the project documentation or contact the maintainers.
|
20
compose.yaml
Normal file
20
compose.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- database
|
||||
database:
|
||||
image: postgres:latest
|
||||
environment:
|
||||
POSTGRES_USER: user
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_DB: appdb
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./database/init:/docker-entrypoint-initdb.d:ro
|
||||
restart: unless-stopped
|
58
deploy/postgresql-deployment.yaml
Normal file
58
deploy/postgresql-deployment.yaml
Normal file
@ -0,0 +1,58 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: postgres-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: postgres-deployment
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:latest
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: mydatabase
|
||||
- name: POSTGRES_USER
|
||||
value: myuser
|
||||
- name: POSTGRES_PASSWORD
|
||||
value: mypassword
|
||||
volumeMounts:
|
||||
- name: postgres-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: postgres-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-pvc
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-service
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: postgres
|
Loading…
Reference in New Issue
Block a user