mirror of
https://github.com/vx3r/wg-gen-web.git
synced 2024-12-19 00:23:27 +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 }}
|
imageName: ${{ env.DOCKER_IMAGE_NAME }}
|
||||||
dockerHubUser: ${{ secrets.DOCKER_LOGIN_USERNAME }}
|
dockerHubUser: ${{ secrets.DOCKER_LOGIN_USERNAME }}
|
||||||
dockerHubPassword: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
dockerHubPassword: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
||||||
|
buildArg: COMMIT=${{ GITHUB_SHA::8 }}
|
@ -7,7 +7,7 @@ build-back:
|
|||||||
stage: build artifacts
|
stage: build artifacts
|
||||||
image: golang:latest
|
image: golang:latest
|
||||||
script:
|
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:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- ${CI_PROJECT_NAME}-linux-amd64
|
- ${CI_PROJECT_NAME}-linux-amd64
|
||||||
@ -16,9 +16,6 @@ build-front:
|
|||||||
stage: build artifacts
|
stage: build artifacts
|
||||||
image: node:10-alpine
|
image: node:10-alpine
|
||||||
script:
|
script:
|
||||||
- apk update
|
|
||||||
- apk upgrade
|
|
||||||
- apk add --no-cache git
|
|
||||||
- cd ./ui
|
- cd ./ui
|
||||||
- npm install
|
- npm install
|
||||||
- npm run build
|
- npm run build
|
||||||
@ -32,7 +29,7 @@ build:
|
|||||||
image: docker:latest
|
image: docker:latest
|
||||||
script:
|
script:
|
||||||
- docker info
|
- 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:
|
push:
|
||||||
stage: push docker hub
|
stage: push docker hub
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
ARG COMMIT="N/A"
|
||||||
|
|
||||||
FROM golang:alpine AS build-back
|
FROM golang:alpine AS build-back
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk update && apk upgrade && apk add --no-cache git
|
ARG COMMIT
|
||||||
COPY . .
|
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
|
FROM node:10-alpine AS build-front
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk update && apk upgrade && apk add --no-cache git
|
|
||||||
COPY ui/package*.json ./
|
COPY ui/package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY ui/ ./
|
COPY ui/ ./
|
||||||
COPY .git .
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/skip2/go-qrcode"
|
"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/core"
|
||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
|
||||||
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ func ApplyRoutes(r *gin.Engine) {
|
|||||||
{
|
{
|
||||||
server.GET("", readServer)
|
server.GET("", readServer)
|
||||||
server.PATCH("", updateServer)
|
server.PATCH("", updateServer)
|
||||||
|
server.GET("/version", version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,3 +202,9 @@ func updateServer(c *gin.Context) {
|
|||||||
|
|
||||||
c.JSON(http.StatusOK, client)
|
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"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
VersionGitCommit string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetFormatter(&log.TextFormatter{})
|
log.SetFormatter(&log.TextFormatter{})
|
||||||
log.SetOutput(os.Stderr)
|
log.SetOutput(os.Stderr)
|
||||||
@ -26,7 +22,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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
|
// load .env environment variables
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"git-describe": "^4.0.4",
|
|
||||||
"is-cidr": "^3.1.0",
|
"is-cidr": "^3.1.0",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
|
@ -24,29 +24,59 @@
|
|||||||
<v-container>
|
<v-container>
|
||||||
<router-view />
|
<router-view />
|
||||||
</v-container>
|
</v-container>
|
||||||
|
<Notification v-bind:notification="notification"/>
|
||||||
</v-content>
|
</v-content>
|
||||||
|
|
||||||
<v-footer app>
|
<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-footer>
|
||||||
|
|
||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import {ApiService} from "./services/ApiService";
|
||||||
|
import Notification from './components/Notification'
|
||||||
|
|
||||||
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Notification
|
||||||
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
VersionGitCommit: process.env.VUE_APP_GIT_HASH
|
api: null,
|
||||||
|
version:'N/A',
|
||||||
|
notification: {
|
||||||
|
show: false,
|
||||||
|
color: '',
|
||||||
|
text: '',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log("Starting Wg Gen Web version: " + process.env.VUE_APP_GIT_HASH)
|
this.api = new ApiService();
|
||||||
|
this.getVersion()
|
||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
created () {
|
||||||
this.$vuetify.theme.dark = true
|
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>
|
</script>
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
const {gitDescribe, gitDescribeSync} = require('git-describe');
|
|
||||||
process.env.VUE_APP_GIT_HASH = gitDescribeSync().hash;
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devServer: {
|
devServer: {
|
||||||
port: 8081,
|
port: 8081,
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
|
|
||||||
var (
|
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])?)*$")
|
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
|
// ReadFile file content
|
||||||
|
Loading…
Reference in New Issue
Block a user