mirror of
https://github.com/vx3r/wg-gen-web.git
synced 2024-12-18 00:13:23 +00:00
This commit is contained in:
parent
a98c39ad04
commit
3e1cd8389d
1
.github/workflows/dockerimage.yml
vendored
1
.github/workflows/dockerimage.yml
vendored
@ -39,3 +39,4 @@ jobs:
|
||||
imageName: ${{ env.DOCKER_IMAGE_NAME }}
|
||||
dockerHubUser: ${{ secrets.DOCKER_LOGIN_USERNAME }}
|
||||
dockerHubPassword: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
||||
buildArg: COMMIT=${{ GITHUB_SHA::8 }}
|
@ -7,7 +7,7 @@ build-back:
|
||||
stage: build artifacts
|
||||
image: golang:latest
|
||||
script:
|
||||
- GOOS=linux GOARCH=amd64 go build -ldflags "-X main.VersionGitCommit=${CI_COMMIT_SHORT_SHA}" -o ${CI_PROJECT_NAME}-linux-amd64
|
||||
- GOOS=linux GOARCH=amd64 go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${CI_COMMIT_SHORT_SHA}'" -o ${CI_PROJECT_NAME}-linux-amd64
|
||||
artifacts:
|
||||
paths:
|
||||
- ${CI_PROJECT_NAME}-linux-amd64
|
||||
@ -16,9 +16,6 @@ build-front:
|
||||
stage: build artifacts
|
||||
image: node:10-alpine
|
||||
script:
|
||||
- apk update
|
||||
- apk upgrade
|
||||
- apk add --no-cache git
|
||||
- cd ./ui
|
||||
- npm install
|
||||
- npm run build
|
||||
@ -32,7 +29,7 @@ build:
|
||||
image: docker:latest
|
||||
script:
|
||||
- docker info
|
||||
- docker build --network br_docker --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} .
|
||||
- docker build --build-arg COMMIT=${CI_COMMIT_SHORT_SHA} --network br_docker --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} .
|
||||
|
||||
push:
|
||||
stage: push docker hub
|
||||
|
@ -1,16 +1,16 @@
|
||||
ARG COMMIT="N/A"
|
||||
|
||||
FROM golang:alpine AS build-back
|
||||
WORKDIR /app
|
||||
RUN apk update && apk upgrade && apk add --no-cache git
|
||||
ARG COMMIT
|
||||
COPY . .
|
||||
RUN GIT_COMMIT=$(git rev-parse --short HEAD) && go build -ldflags "-X main.VersionGitCommit=$GIT_COMMIT" go build -o wg-gen-web-linux
|
||||
RUN go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${COMMIT}'" -o wg-gen-web-linux
|
||||
|
||||
FROM node:10-alpine AS build-front
|
||||
WORKDIR /app
|
||||
RUN apk update && apk upgrade && apk add --no-cache git
|
||||
COPY ui/package*.json ./
|
||||
RUN npm install
|
||||
COPY ui/ ./
|
||||
COPY .git .
|
||||
RUN npm run build
|
||||
|
||||
FROM alpine
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/skip2/go-qrcode"
|
||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
|
||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
|
||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -27,6 +28,7 @@ func ApplyRoutes(r *gin.Engine) {
|
||||
{
|
||||
server.GET("", readServer)
|
||||
server.PATCH("", updateServer)
|
||||
server.GET("/version", version)
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,3 +202,9 @@ func updateServer(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, client)
|
||||
}
|
||||
|
||||
func version(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"version": util.Version,
|
||||
})
|
||||
}
|
||||
|
6
main.go
6
main.go
@ -15,10 +15,6 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
VersionGitCommit string
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetFormatter(&log.TextFormatter{})
|
||||
log.SetOutput(os.Stderr)
|
||||
@ -26,7 +22,7 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Infof("Starting Wg Gen Web version: %s", VersionGitCommit)
|
||||
log.Infof("Starting Wg Gen Web version: %s", util.Version)
|
||||
|
||||
// load .env environment variables
|
||||
err := godotenv.Load()
|
||||
|
@ -8,7 +8,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"git-describe": "^4.0.4",
|
||||
"is-cidr": "^3.1.0",
|
||||
"moment": "^2.24.0",
|
||||
"vue": "^2.6.10",
|
||||
|
@ -24,29 +24,59 @@
|
||||
<v-container>
|
||||
<router-view />
|
||||
</v-container>
|
||||
<Notification v-bind:notification="notification"/>
|
||||
</v-content>
|
||||
|
||||
<v-footer app>
|
||||
<span>License <a class="pr-1 pl-1" href="http://www.wtfpl.net/" target="_blank">WTFPL</a> © {{ new Date().getFullYear() }} Created with</span><v-icon class="pr-1 pl-1">mdi-heart</v-icon><span>by</span><a class="pr-1 pl-1" href="mailto:vx3r@127-0-0-1.fr">vx3r</a><v-spacer></v-spacer><span>Version: {{ VersionGitCommit }}</span>
|
||||
<span>License <a class="pr-1 pl-1" href="http://www.wtfpl.net/" target="_blank">WTFPL</a> © {{ new Date().getFullYear() }} Created with</span><v-icon class="pr-1 pl-1">mdi-heart</v-icon><span>by</span><a class="pr-1 pl-1" href="mailto:vx3r@127-0-0-1.fr">vx3r</a><v-spacer></v-spacer><span>Version: {{ version }}</span>
|
||||
</v-footer>
|
||||
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {ApiService} from "./services/ApiService";
|
||||
import Notification from './components/Notification'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
|
||||
components: {
|
||||
Notification
|
||||
},
|
||||
|
||||
data: () => ({
|
||||
VersionGitCommit: process.env.VUE_APP_GIT_HASH
|
||||
api: null,
|
||||
version:'N/A',
|
||||
notification: {
|
||||
show: false,
|
||||
color: '',
|
||||
text: '',
|
||||
},
|
||||
}),
|
||||
|
||||
mounted() {
|
||||
console.log("Starting Wg Gen Web version: " + process.env.VUE_APP_GIT_HASH)
|
||||
this.api = new ApiService();
|
||||
this.getVersion()
|
||||
},
|
||||
|
||||
created () {
|
||||
this.$vuetify.theme.dark = true
|
||||
},
|
||||
|
||||
methods: {
|
||||
getVersion() {
|
||||
this.api.get('/server/version').then((res) => {
|
||||
this.version = res.version;
|
||||
}).catch((e) => {
|
||||
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
||||
});
|
||||
},
|
||||
notify(color, msg) {
|
||||
this.notification.show = true;
|
||||
this.notification.color = color;
|
||||
this.notification.text = msg;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,6 +1,3 @@
|
||||
const {gitDescribe, gitDescribeSync} = require('git-describe');
|
||||
process.env.VUE_APP_GIT_HASH = gitDescribeSync().hash;
|
||||
|
||||
module.exports = {
|
||||
devServer: {
|
||||
port: 8081,
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
|
||||
var (
|
||||
RegexpEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||
// pushed build time
|
||||
Version string
|
||||
)
|
||||
|
||||
// ReadFile file content
|
||||
|
Loading…
Reference in New Issue
Block a user