Skip to content

Commit

Permalink
feat(server): dockerize server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 15, 2024
1 parent 1c36c21 commit d684221
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
server:
build: .
container_name: copluk-server
restart: always
ports:
- "80:80"
volumes:
- .:/app
depends_on:
- mongo

mongo:
image: mongo:latest
container_name: copluk-mongo
restart: always
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db

volumes:
mongo-data:
10 changes: 4 additions & 6 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
MODE=development

MONGO_URI=mongodb://localhost:27017/

MODE=production
JWT_SECRET=secret

CLIENT_HOST=http://localhost:3000
PORT=5000
MONGO_URI=mongodb://mongo:27017/
CLIENT_HOST=https://copl.uk
PORT=80
13 changes: 13 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.22.4-alpine AS builder
WORKDIR /app
COPY . .
RUN go mod tidy
RUN go build -o server

FROM alpine:latest
WORKDIR /root/
COPY --from=builder /app/server .
COPY --from=builder /app/.env .

EXPOSE 80
CMD ["./server"]

0 comments on commit d684221

Please sign in to comment.