Skip to content

Commit

Permalink
feat: dockerize
Browse files Browse the repository at this point in the history
and create docker-compose.yml for development purposes (and more,
possibly)
  • Loading branch information
fedragon committed Sep 29, 2023
1 parent 0e6c1c0 commit 42d95ef
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -x ARK_CLIENT_FILE_TYPES "cr2,heic,jpg,jpeg,mov,orf"
set -x ARK_CLIENT_SERVER_ADDRESS "localhost:9999"
set -x ARK_CLIENT_SERVER_PROTOCOL "http"
set -x ARK_CLIENT_SIGNING_KEY "supersecret"
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
bin/
docker/data/

.env
*.db

TODO.md
TODO.md
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.21-alpine3.18 AS builder
WORKDIR $GOPATH/src/github.com/fedragon/ark
COPY . .
RUN CGO_ENABLED=0 go build -o bin/server cmd/server/main.go

FROM alpine:3.18
RUN adduser -D ark -u 5000
USER ark
COPY --from=builder /go/src/github.com/fedragon/ark/bin/server /bin/server
EXPOSE 9999
ENTRYPOINT ["/bin/server"]
9 changes: 9 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARK_HOST_PORT="9999"
ARK_ARCHIVE_PATH="./data/archive"

PROMETHEUS_CONFIG_PATH="./prometheus.yml"
PROMETHEUS_DATA_PATH="./data/prometheus"
PROMETHEUS_HOST_PORT=9090

REDIS_HOST_PORT=6379
REDIS_DATA_PATH="./data/redis"
68 changes: 68 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: "3.9"
name: ark

services:
prometheus:
image: prom/prometheus:v2.47.0
volumes:
- $PROMETHEUS_CONFIG_PATH:/etc/prometheus/prometheus.yml
- $PROMETHEUS_DATA_PATH:/prometheus
ports:
- "$PROMETHEUS_HOST_PORT:9090"

redis:
image: redis:7.2.1
volumes:
- $REDIS_DATA_PATH:/data
entrypoint:
- redis-server
- --save 30 1
ports:
- "$REDIS_HOST_PORT:6379"

server:
# image: fedragon/ark:latest
build:
context: ..
ports:
- "$ARK_HOST_PORT:9999"
volumes:
- ark_data:/ark
environment:
ARK_SERVER_ADDRESS: "0.0.0.0:9999"
ARK_SERVER_ARCHIVE_PATH: /ark
ARK_SERVER_REDIS_ADDRESS: "redis:6379"
ARK_SERVER_REDIS_DATABASE: 0
secrets:
- server
entrypoint:
- bin/sh
- -c
- 'source /run/secrets/server && /bin/server'
depends_on:
- prometheus
- redis

secrets:
server:
file: ./secrets/server

volumes:
ark_data:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '$ARK_ARCHIVE_PATH'
prometheus_data:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '$PROMETHEUS_DATA_PATH'
redis_data:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '$REDIS_DATA_PATH'
2 changes: 1 addition & 1 deletion prometheus.yml → docker/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ scrape_configs:
tls_config:
insecure_skip_verify: true
static_configs:
- targets: [ '192.168.1.90:9999' ]
- targets: [ 'ark:9999' ]
1 change: 1 addition & 0 deletions docker/secrets/server
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export ARK_SERVER_SIGNING_KEY=supersecret

0 comments on commit 42d95ef

Please sign in to comment.