mirror of
https://github.com/davegallant/rfd-fyi.git
synced 2025-08-05 06:53:40 +00:00
Add Dockerfile
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,21 +1,20 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.18-alpine
|
||||
|
||||
# hadolint ignore=DL3018
|
||||
RUN apk --no-cache add \
|
||||
gcc \
|
||||
musl-dev
|
||||
FROM node:18-alpine3.16 as build-stage
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY backend/ .
|
||||
COPY package*.json ./
|
||||
|
||||
RUN CGO_ENABLED=1 GOOS=linux \
|
||||
go build -o /rfd-fyi \
|
||||
# Additional flags are necessary for sqlite support
|
||||
-a -ldflags '-linkmode external -extldflags "-static"' .
|
||||
RUN yarn install
|
||||
|
||||
EXPOSE 8080
|
||||
COPY . .
|
||||
|
||||
CMD [ "/rfd-fyi" ]
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:stable-alpine as production-stage
|
||||
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
64
Makefile
64
Makefile
@@ -1,64 +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-fyi
|
||||
.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
|
||||
|
||||
## seed: Generate several issues via the create endpoint
|
||||
seed:
|
||||
BASE_PATH=$(BASE_PATH) ./scripts/generate-issues.sh
|
||||
.PHONY: seed
|
||||
|
||||
## container: Build a container image with Docker
|
||||
container:
|
||||
docker build . -t rfd-fyi
|
||||
.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-fyi" \
|
||||
rfd-fyi
|
||||
.PHONY: container-run
|
21
backend/Dockerfile
Normal file
21
backend/Dockerfile
Normal 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" ]
|
@@ -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
|
@@ -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/
|
||||
|
@@ -1,4 +1,4 @@
|
||||
module github.com/davegallant/rfd-launcher
|
||||
module github.com/davegallant/rfd-fyi
|
||||
|
||||
go 1.18
|
||||
|
||||
|
@@ -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/
|
||||
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
frontend:
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- 80:80
|
||||
links:
|
||||
- "backend:backend"
|
||||
backend:
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: backend
|
||||
ports:
|
||||
- 8080:8080
|
30
nginx.conf
Normal file
30
nginx.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
upstream backend {
|
||||
server backend:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "rfd-launcher",
|
||||
"name": "rfd-fyi",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rfd-launcher",
|
||||
"name": "rfd-fyi",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.5",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "rfd-launcher",
|
||||
"name": "rfd-fyi",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@@ -38,7 +38,7 @@
|
||||
></a>
|
||||
</td>
|
||||
<td scope="col">{{ topic.total_views }}</td>
|
||||
<td scope="col">{{ topic.votes.up - topic.votes.down }}</td>
|
||||
<!-- <td scope="col">{{ topic.votes.up - topic.votes.down }}</td> -->
|
||||
<td scope="col">{{ formatDate(topic.last_post_time) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -75,7 +75,7 @@ export default {
|
||||
},
|
||||
fetchDeals() {
|
||||
axios
|
||||
.get("http://localhost:8081/api/v1/topics")
|
||||
.get("api/v1/topics")
|
||||
.then((response) => {
|
||||
this.topics = response.data;
|
||||
this.isLoading = false;
|
||||
|
@@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
props: {
|
||||
msg: String
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
@@ -1,7 +1,7 @@
|
||||
const { defineConfig } = require('@vue/cli-service')
|
||||
const { defineConfig } = require("@vue/cli-service");
|
||||
module.exports = defineConfig({
|
||||
transpileDependencies: true,
|
||||
devServer: {
|
||||
proxy: 'http://localhost:8080'
|
||||
}
|
||||
})
|
||||
proxy: "http://localhost:8080",
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user