1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

Change paths to use woodpecker instead of drone (#494)

* change paths to use woodpecker instead of drone

* improve sql file migration

* add migration notice
This commit is contained in:
Anbraten 2021-10-28 21:02:43 +02:00 committed by GitHub
parent 91d37be1da
commit 06800cb61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 13 deletions

View File

@ -20,7 +20,7 @@ extraSecretNamesForEnvFrom:
persistentVolume:
enabled: true
size: 10Gi
mountPath: "/var/lib/drone"
mountPath: "/var/lib/woodpecker"
storageClass: "gp2"
imagePullSecrets: []

View File

@ -173,7 +173,7 @@ var flags = []cli.Flag{
EnvVars: []string{"WOODPECKER_DATABASE_DATASOURCE"},
Name: "datasource",
Usage: "database driver configuration string",
Value: "drone.sqlite",
Value: "woodpecker.sqlite",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_PROMETHEUS_AUTH_TOKEN"},

View File

@ -16,6 +16,7 @@ package main
import (
"fmt"
"os"
"time"
"github.com/gin-gonic/gin"
@ -45,6 +46,10 @@ import (
)
func setupStore(c *cli.Context) (store.Store, error) {
if err := migrateSqlFile(c); err != nil {
log.Fatal().Err(err).Msg("could not migrate legacy sqlite file")
}
opts := &datastore.Opts{
Driver: c.String("driver"),
Config: c.String("datasource"),
@ -53,6 +58,31 @@ func setupStore(c *cli.Context) (store.Store, error) {
return datastore.New(opts)
}
// TODO Remove this once we are sure users aren't attempting to migrate from Drone to Woodpecker (possibly never)
func migrateSqlFile(c *cli.Context) error {
// default config for docker containers
if c.String("datasource") == "/var/lib/woodpecker/woodpecker.sqlite" {
_, err := os.Stat("/var/lib/drone/drone.sqlite")
if err == nil {
return os.Rename("/var/lib/drone/drone.sqlite", "/var/lib/woodpecker/woodpecker.sqlite")
} else if !os.IsNotExist(err) {
return err
}
}
// default config for standalone installations
if c.String("datasource") == "woodpecker.sqlite" {
_, err := os.Stat("drone.sqlite")
if err == nil {
return os.Rename("drone.sqlite", "woodpecker.sqlite")
} else if err != nil && !os.IsNotExist(err) {
return err
}
}
return nil
}
func setupQueue(c *cli.Context, s store.Store) queue.Queue {
return model.WithTaskStore(queue.New(), s)
}

View File

@ -9,7 +9,7 @@ services:
ports:
- 8000:8000
volumes:
- /var/lib/drone:/var/lib/drone/
- /var/lib/woodpecker:/var/lib/woodpecker/
environment:
- WOODPECKER_OPEN=true
- WOODPECKER_ADMIN=laszlocph

View File

@ -11,9 +11,9 @@ COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.
EXPOSE 8000 9000 80 443
ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/woodpecker/woodpecker.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ENV XDG_CACHE_HOME=/var/lib/woodpecker
ADD dist/server/linux_amd64/woodpecker-server /bin/

View File

@ -6,9 +6,9 @@ RUN apk add -U --no-cache ca-certificates
EXPOSE 8000 9000 80 443
ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/woodpecker/woodpecker.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ENV XDG_CACHE_HOME=/var/lib/woodpecker
ADD dist/server/linux_amd64/woodpecker-server /bin/

View File

@ -33,7 +33,7 @@ services:
ports:
- 8000:8000
volumes:
- woodpecker-server-data:/var/lib/drone/
- woodpecker-server-data:/var/lib/woodpecker/
environment:
- WOODPECKER_OPEN=true
- WOODPECKER_HOST=${WOODPECKER_HOST}

View File

@ -4,7 +4,7 @@ The default database engine of Woodpecker is an embedded SQLite database which r
## Configure sqlite
By default Woodpecker uses a sqlite database stored under `/var/lib/drone/`. You can mount a [data volume](https://docs.docker.com/storage/volumes/#create-and-manage-volumes) to persist the sqlite database.
By default Woodpecker uses a sqlite database stored under `/var/lib/woodpecker/`. You can mount a [data volume](https://docs.docker.com/storage/volumes/#create-and-manage-volumes) to persist the sqlite database.
```diff
# docker-compose.yml
@ -14,7 +14,7 @@ services:
woodpecker-server:
[...]
+ volumes:
+ - woodpecker-server-data:/var/lib/drone/
+ - woodpecker-server-data:/var/lib/woodpecker/
```
## Configure MySQL

View File

@ -35,7 +35,7 @@ Note that Woodpecker uses the hostname from the `WOODPECKER_HOST` environment va
Woodpecker writes the certificates to the below directory:
```
/var/lib/drone/golang-autocert
/var/lib/woodpecker/golang-autocert
```
### Certificate Updates

View File

@ -95,7 +95,7 @@ spec:
value: "xxx"
volumeMounts:
- name: sqlite-volume
mountPath: /var/lib/drone
mountPath: /var/lib/woodpecker
volumes:
- name: sqlite-volume
persistentVolumeClaim:

View File

@ -24,6 +24,12 @@ Some versions need some changes to the server configuration or the pipeline conf
- Prometheus metrics have been changed from `drone_*` to `woodpecker_*`
- Base path has moved from `/var/lib/drone` to `/var/lib/woodpecker`
- Default SQLite database location has changed:
- `/var/lib/drone/drone.sqlite` -> `/var/lib/woodpecker/woodpecker.sqlite`
- `drone.sqlite` -> `woodpecker.sqlite`
- ...
## 0.14.0

View File

@ -245,7 +245,7 @@ func (b *ProcBuilder) toInternalRepresentation(parsed *yaml.Config, environ map[
),
),
compiler.WithProxy(),
compiler.WithWorkspaceFromURL("/drone", b.Repo.Link),
compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.Link),
compiler.WithMetadata(metadata),
).Compile(parsed)
}