Skip to content

Commit

Permalink
Merge pull request #1 from nieuwsma/training
Browse files Browse the repository at this point in the history
Training
  • Loading branch information
nieuwsma authored Sep 2, 2023
2 parents 6833bb8 + 738103d commit 31aca69
Show file tree
Hide file tree
Showing 1,383 changed files with 1,042 additions and 633,900 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
bin/
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright

# Dockerfile for building Dimension server
# Build base just has the packages installed we need.
FROM golang:1.20-alpine AS build-base
RUN echo "GOPATH is set to: $GOPATH"

RUN set -ex \
&& apk -U upgrade \
&& apk add build-base

# Base copies in the files we need to test/build.
FROM build-base AS base


RUN go env -w GO111MODULE=auto

# Copy all the necessary files to the image.
COPY cmd $GOPATH/src/github.com/nieuwsma/dimension/cmd
COPY vendor $GOPATH/src/github.com/nieuwsma/dimension/vendor
COPY pkg $GOPATH/src/github.com/nieuwsma/dimension/pkg
COPY internal $GOPATH/src/github.com/nieuwsma/dimension/internal
COPY .version $GOPATH/src/github.com/nieuwsma/dimension/.version

### Build Stage ###
FROM base AS builder

RUN set -ex && go build -v -o /usr/local/bin/server github.com/nieuwsma/dimension/cmd/server

### Final Stage ###

FROM alpine:3
LABEL maintainer="Nieuwsma"
EXPOSE 28007
STOPSIGNAL SIGTERM

RUN set -ex \
&& apk -U upgrade

# Get the system-power-capping-service from the builder stage.
COPY --from=builder /usr/local/bin/server /usr/local/bin/.
COPY .version /


ENV LOG_LEVEL "TRACE"
ENV PORT "8080"

#nobody 65534:65534
USER 65534:65534

CMD ["sh", "-c", "server $@"]
24 changes: 24 additions & 0 deletions Dockerfile.test.unit.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright
# This file only exists as a means to run tests in an automated fashion.

FROM golang:1.20-alpine

RUN set -ex \
&& apk -U upgrade \
&& apk add build-base
ENV LOG_LEVEL "WARN"
ENV TEST_DIR "$GOPATH/src/github.com/nieuwsma/dimension/pkg/logic/test_cases"


RUN go env -w GO111MODULE=auto

COPY cmd $GOPATH/src/github.com/nieuwsma/dimension/cmd
COPY vendor $GOPATH/src/github.com/nieuwsma/dimension/vendor
COPY pkg $GOPATH/src/github.com/nieuwsma/dimension/pkg
COPY internal $GOPATH/src/github.com/nieuwsma/dimension/internal
COPY .version $GOPATH/src/github.com/nieuwsma/dimension/.version

CMD set -ex \
&& go version \
&& go test -cover -v -o dimension github.com/nieuwsma/dimension/internal/api \
&& go test -cover -v -o dimension github.com/nieuwsma/dimension/pkg/logic
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright

# Service
NAME ?= dimension
VERSION ?= $(shell cat .version)


all: image unittest server

binary: server

#create server binary
server:
go build -v -o bin/server github.com/nieuwsma/dimension/cmd/server

#create docker image for server
image:
docker build --pull ${DOCKER_ARGS} --tag '${NAME}:${VERSION}' -f Dockerfile .

#run all tests
test: unittest

#run unit tests
unittest:
./runUnitTest.sh

#empty the bin
clean:
rm bin/*

#generate lines of code in project
cloc:
cloc --exclude-dir=vendor,data_processing,test,.docker,.DS_Store,.git,.idea,bin,configs --exclude-ext=.json,JSON --exclude-lang=JSON .
Loading

0 comments on commit 31aca69

Please sign in to comment.