Add Dockerfile

This commit is contained in:
Dave Gallant
2022-08-21 04:50:53 +00:00
parent 9605d395f4
commit e9c470a817
15 changed files with 94 additions and 210 deletions

21
backend/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1
FROM golang:1.18-alpine as go-build
# hadolint ignore=DL3018
RUN apk --no-cache add \
gcc \
musl-dev
COPY . /backend
WORKDIR /backend
RUN CGO_ENABLED=1 GOOS=linux \
go build -o server \
# Additional flags are necessary for sqlite support
-a -ldflags '-linkmode external -extldflags "-static"' .
EXPOSE 8080
CMD [ "/backend/server" ]

View File

@@ -1,59 +0,0 @@
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
BASE_PATH ?= "http://localhost:8080"
## help: Print this help message
help:
@echo
@echo "Usage:"
@echo
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort
@echo
.PHONY: help
## build: Build the binary
build:
@mkdir -p bin
go build -o bin/rfd-launcher
.PHONY: build
## test: Run tests in colour
test:
@go install github.com/rakyll/gotest@latest
gotest -v -count=1
.PHONY: test
## fmt: Format code (with gofumpt)
fmt:
@go install mvdan.cc/gofumpt@latest
gofumpt -w .
.PHONY: fmt
## swagger: Generate swagger docs
swagger:
@go install github.com/swaggo/swag/cmd/swag@latest
swag init --outputTypes yaml
.PHONY: swagger
## server: Build and run server from source
server:
@go run .
.PHONY: server
## container: Build a container image with Docker
container:
docker build . -t rfd-launcher
.PHONY: container
## container-run: Build and run a container with Docker
container-run: container
@docker run \
--network host \
-u "$$(id -u)":"$$(id -g)"\
-v "$$PWD":"/opt/rfd-launcher" \
rfd-launcher
.PHONY: container-run

View File

@@ -14,7 +14,7 @@ import (
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
// @title RFD LAUNCHER API
// @title RFD FYI API
// @version 1.0
// @description An API for issue tracking
// @termsOfService http://swagger.io/terms/

View File

@@ -1,4 +1,4 @@
module github.com/davegallant/rfd-launcher
module github.com/davegallant/rfd-fyi
go 1.18

View File

@@ -10,10 +10,10 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
utils "github.com/davegallant/rfd-launcher/pkg/utils"
utils "github.com/davegallant/rfd-fyi/pkg/utils"
)
// @title RFD Launcher API
// @title RFD FYI API
// @version 1.0
// @description An API for an issue tracking service
// @termsOfService http://swagger.io/terms/