Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 1b01105

Browse files
author
Noah Hanjun Lee
authored
Separate the community edition from the enterprise edition (#184)
* Add oss tag to the 'db.go' file * Add lock of OSS version * Fix to handle 402 error differently for OSS version * Add approval file of OSS version * Add event file of OSS version * Add slack package of OSS version * Fix Dockerfile to support community edition * Fix the license for OSS edition
1 parent dbb783c commit 1b01105

File tree

21 files changed

+390
-183
lines changed

21 files changed

+390
-183
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
docs/
55
README.md
66
.env
7-
falcon9.db
7+
sqlite3.db
88

99
# ui
1010
ui/node_modules

BUILDING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. Clone the repository
2+
2. Build the Docker image:
3+
4+
docker build -t gitploy .

BUILDING_OSS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. Clone the repository
2+
2. Build the Docker image:
3+
4+
docker build -t gitploy --build-arg "OSS=true" .

Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
# Build the server binary file.
22
FROM golang:1.15 AS server
3+
ARG OSS=false
34

45
WORKDIR /server
56

67
COPY go.mod go.sum ./
78
RUN go mod download
89

910
COPY . .
10-
RUN go install ./cmd/server
11+
RUN if [ "${OSS}" = "false" ]; then \
12+
echo "Build the enterprise edition"; \
13+
go build -o gitploy-server ./cmd/server; \
14+
else \
15+
echo "Build the community edition"; \
16+
go build -o gitploy-server -tags "oss" ./cmd/server; \
17+
fi
1118

1219
# Build UI.
1320
FROM node:14.17.0 AS ui
21+
ARG OSS=false
1422

1523
WORKDIR /ui
1624

@@ -20,6 +28,7 @@ COPY ./ui/package.json ./ui/package-lock.json ./
2028
RUN npm install --silent
2129

2230
COPY ./ui ./
31+
ENV REACT_APP_GITPLOY_OSS="${OSS}"
2332
RUN npm run build
2433

2534
# Copy to the final image.
@@ -30,10 +39,10 @@ WORKDIR /app
3039
# Create DB
3140
RUN mkdir /data
3241

33-
COPY --from=server --chown=root:root /server/LICENSE /server/NOTICE .
34-
COPY --from=server --chown=root:root /go/bin/server /go/bin/server
42+
COPY --from=server --chown=root:root /server/LICENSE /server/NOTICE ./
43+
COPY --from=server --chown=root:root /server/gitploy-server /go/bin/gitploy-server
3544

3645
# Copy UI output into the assets directory.
3746
COPY --from=ui --chown=root:root /ui/build/ /app/
3847

39-
ENTRYPOINT [ "/go/bin/server" ]
48+
ENTRYPOINT [ "/go/bin/gitploy-server" ]

LICENSE

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Copyright 2021 Gitploy.IO, Inc.
22

3+
The Gitploy Community Edition is licensed under the Apache License,
4+
Version 2.0 (the "Apache License").
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
The source files in this repository are under the Apache License
9+
basically, but some files are under the Gitploy Non-Commercial License.
10+
The header of files indicating which license they are under.
11+
312
The Gitploy Enterprise Edition is licensed under the Gitploy
413
Non-Commercial License (the "Non-Commercial License"). A copy of
514
the Non-Commercial License is provided below.
@@ -20,8 +29,7 @@ software that would otherwise infringe either the contributor's
2029
copyright in it.
2130

2231
1. You must limit use of this software in any manner primarily
23-
intended for commercial advantage or private monetary compensation
24-
to the count of user limit.
32+
intended for commercial advantage or private monetary compensation.
2533
This limit does not apply to use in developing feedback or extensions
2634
that you contribute back to those giving this license.
2735

cmd/server/db.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Copyright 2021 Gitploy.IO Inc. All rights reserved.
2+
// Use of this source code is governed by the Gitploy Non-Commercial License
3+
// that can be found in the LICENSE file.
4+
5+
// +build !oss
6+
17
package main
28

39
import (

cmd/server/db_oss.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build oss
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
8+
"entgo.io/ent/dialect"
9+
"github.com/gitploy-io/gitploy/ent"
10+
)
11+
12+
func OpenDB(driver string, dsn string) (*ent.Client, error) {
13+
if driver != dialect.SQLite {
14+
return nil, fmt.Errorf("The community edition support sqlite only.")
15+
}
16+
17+
return ent.Open(driver, dsn)
18+
}

internal/server/api/v1/repos/approval.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Copyright 2021 Gitploy.IO Inc. All rights reserved.
2+
// Use of this source code is governed by the Gitploy Non-Commercial License
3+
// that can be found in the LICENSE file.
4+
5+
// +build !oss
6+
17
package repos
28

39
import (
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// +build oss
2+
3+
package repos
4+
5+
import (
6+
"net/http"
7+
8+
"github.com/gin-gonic/gin"
9+
10+
"github.com/gitploy-io/gitploy/ent"
11+
gb "github.com/gitploy-io/gitploy/internal/server/global"
12+
)
13+
14+
func (r *Repo) ListApprovals(c *gin.Context) {
15+
gb.Response(c, http.StatusOK, make([]*ent.Approval, 0))
16+
}
17+
18+
func (r *Repo) GetApproval(c *gin.Context) {
19+
gb.Response(c, http.StatusNotFound, nil)
20+
}
21+
22+
func (r *Repo) GetMyApproval(c *gin.Context) {
23+
gb.Response(c, http.StatusNotFound, nil)
24+
}
25+
26+
func (r *Repo) CreateApproval(c *gin.Context) {
27+
gb.ErrorResponse(c, http.StatusPaymentRequired, "It is limited to the community edition.")
28+
}
29+
30+
func (r *Repo) UpdateMyApproval(c *gin.Context) {
31+
gb.ErrorResponse(c, http.StatusPaymentRequired, "It is limited to the community edition.")
32+
}
33+
34+
func (r *Repo) DeleteApproval(c *gin.Context) {
35+
gb.ErrorResponse(c, http.StatusPaymentRequired, "It is limited to the community edition.")
36+
}

internal/server/api/v1/repos/lock.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Copyright 2021 Gitploy.IO Inc. All rights reserved.
2+
// Use of this source code is governed by the Gitploy Non-Commercial License
3+
// that can be found in the LICENSE file.
4+
5+
// +build !oss
6+
17
package repos
28

39
import (

0 commit comments

Comments
 (0)