Skip to content

Commit c27a832

Browse files
committed
Added dockerfile
1 parent 6d2a945 commit c27a832

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,33 @@ MAKEFLAGS += --no-builtin-rules
1010
OPENRUN_HOME := `pwd`
1111
INPUT := $(word 2,$(MAKECMDGOALS))
1212

13+
ARCH := $(shell uname -m)
14+
TARGET_DIR := dist/linux/$(ARCH)
15+
BINARY := openrun
16+
IMAGE_TAG := openrun:latest
17+
1318
.DEFAULT_GOAL := help
1419
ifeq ($(origin .RECIPEPREFIX), undefined)
1520
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
1621
endif
1722
.RECIPEPREFIX = >
1823
TAG :=
1924

20-
.PHONY: help test unit int covtest covunit covint release int_single lint verify
25+
.PHONY: help test unit int covtest covunit covint release int_single lint verify build-linux image
2126

2227
help: ## Display this help section
2328
> @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-38s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
2429

2530
test: unit int ## Run all tests
2631
verify: lint test ## Run lint and all tests
2732

33+
build-linux: ## Build linux binary into dist/
34+
> mkdir -p $(TARGET_DIR)
35+
> CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -o $(TARGET_DIR)/$(BINARY) ./cmd/openrun
36+
37+
image: build-linux ## Build docker image
38+
> docker build -f deploy/Dockerfile -t $(IMAGE_TAG) dist
39+
2840
covtest: covunit covint ## Run all tests with coverage
2941
> go tool covdata percent -i=$(OPENRUN_HOME)/coverage/client,$(OPENRUN_HOME)/coverage/unit,$(OPENRUN_HOME)/coverage/int
3042
> go tool covdata textfmt -i=$(OPENRUN_HOME)/coverage/client,$(OPENRUN_HOME)/coverage/unit,$(OPENRUN_HOME)/coverage/int -o $(OPENRUN_HOME)/coverage.txt

deploy/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) ClaceIO, LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM alpine:3.22.2
5+
ARG TARGETARCH
6+
ENV OPENRUN_HOME=/var/lib/openrun
7+
8+
# Create non-root user and directories
9+
RUN addgroup -S openrun \
10+
&& adduser -S -G openrun -h /home/openrun openrun \
11+
&& mkdir -p "${OPENRUN_HOME}" \
12+
&& chown -R openrun:openrun "${OPENRUN_HOME}"
13+
14+
COPY linux/${TARGETARCH}/openrun /usr/bin/openrun
15+
16+
USER openrun
17+
EXPOSE 25222
18+
EXPOSE 25223
19+
20+
CMD ["/usr/bin/openrun", "server", "start"]
21+

0 commit comments

Comments
 (0)