Skip to content
Closed
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
53 changes: 46 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Install Stage
FROM golang:1.23.2 AS install-stage

WORKDIR /build
Expand All @@ -20,14 +21,11 @@ RUN make generate && go vet ./...
RUN make css
RUN make release

# Default final base image to Alpine Linux
# Production Stage
FROM alpine:3.21 AS production

# Ensure we have latest packages applied
RUN apk update \
&& apk upgrade
RUN apk update && apk upgrade

# Create a non-root user
RUN addgroup -g 10001 -S iota-user \
&& adduser --disabled-password --gecos '' -u 10000 --home /home/iota-user iota-user -G iota-user \
&& chown -R iota-user:iota-user /home/iota-user
Expand All @@ -40,13 +38,54 @@ ENV PATH=/home/iota-user:$PATH
USER iota-user
ENTRYPOINT run_server

# Staging Stage
FROM install-stage AS staging
RUN go build -o run_server cmd/server/main.go && go build -o seed_db cmd/seed/main.go
CMD go run cmd/migrate/main.go up && /build/seed_db && /build/run_server

# Testing CI Stage
FROM install-stage AS testing-ci
#CMD golangci-lint run && go test -v ./...
CMD [ "go", "test", "-v", "./..." ]

# Testing Local Stage
FROM install-stage AS testing-local
CMD [ "gow", "test", "./..." ]
CMD [ "gow", "test", "./..." ]

# Development Stage
FROM golang:1.23.2-alpine AS dev

WORKDIR /app

# Install required system dependencies
RUN apk add --no-cache \
gcc \
musl-dev \
git \
curl \
make

# Install Air for hot reloading
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.5

# Install TailwindCSS
RUN case "$(uname -m)" in \
"x86_64") ARCH="x64" ;; \
"aarch64") ARCH="arm64" ;; \
*) echo "Unsupported architecture: $(uname -m)" && exit 1 ;; \
esac && \
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.15/tailwindcss-linux-${ARCH} && \
chmod +x tailwindcss-linux-${ARCH} && \
mv tailwindcss-linux-${ARCH} /usr/local/bin/tailwindcss

# Install templ
RUN go install github.com/a-h/templ/cmd/[email protected]

# Copy Go modules and install dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy application source code
COPY . .

# Set Air to run on container startup
ENTRYPOINT ["air"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ coverage-score:
report:
go tool cover -html=coverage.out -o ./coverage/cover.html

# Dev containers
dev-docker:
docker compose -f docker-compose.dev-docker.yml up --build

# Run PostgreSQL
localdb:
docker compose -f docker-compose.dev.yml up
docker compose -f docker-compose.dev.yml up -d

clear-localdb:
rm -rf postgres-data/
Expand Down Expand Up @@ -92,4 +96,4 @@ run-iota-linter:
clean-iota-linter:
rm -f bin/iotalinter

.PHONY: default deps test test-watch localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter
.PHONY: default deps test test-watch dev-docker localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter
39 changes: 39 additions & 0 deletions docker-compose.dev-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
target: dev
ports:
- "8090:8090"
- "8080:8080"
- "3200:3200"
volumes:
- .:/app
- go-modules:/go/pkg/mod
environment:
- DB_HOST=db
- DB_USER=postgres
- DB_PASSWORD=postgres
- DB_NAME=iota_erp
- DB_PORT=5432
depends_on:
- db

db:
image: postgres:15.1
restart: always
command: [ "postgres", "-c", "log_statement=all", "-c", "log_destination=stderr", "-c", "logging_collector=off" ]
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: iota_erp
ports:
- "5432:5432"
volumes:
- ./postgres-data:/var/lib/postgresql/data

volumes:
go-modules:
26 changes: 24 additions & 2 deletions docs/CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Before starting, ensure the following tools are installed on your system:

## 🛠️ Development Setup

### Setup Locally
1. **Clone the repository**:
```bash
git clone https://github.com/iota-uz/iota-sdk.git
Expand Down Expand Up @@ -59,7 +60,28 @@ Before starting, ensure the following tools are installed on your system:
air
```

9. **Access the web app**:
### Setup With Docker
1. **Clone the repository**:
```bash
git clone https://github.com/iota-uz/iota-sdk.git
```

2. **Make env file**:
```bash
cp .env.example .env
```

3. **Run the project using Docker**:
```bash
make dev-docker
```

4. **Apply database migrations and seed data**:
```bash
make migrate-up && make seed
```

### Access the web app

Open your browser and navigate to:
[http://localhost:8080](http://localhost:8080)
Expand All @@ -75,6 +97,6 @@ Before starting, ensure the following tools are installed on your system:
TestPass123!
```

10. **Access the GraphQL Schema**:
- **Access the GraphQL Schema**:
Open Postman and connect to:
[http://localhost:3200/query](http://localhost:3200/query)