2020-03-04 22:10:58 +00:00
# Build SFTPGo from source
2020-12-02 08:44:18 +00:00
Download the sources and use `go build` .
2020-03-04 22:10:58 +00:00
2020-05-23 10:47:44 +00:00
The following build tags are available:
2020-05-23 09:58:05 +00:00
2020-05-23 10:47:44 +00:00
- `nogcs` , disable Google Cloud Storage backend, default enabled
2020-06-19 15:08:51 +00:00
- `nos3` , disable S3 Compabible Object Storage backends, default enabled
2020-10-25 07:18:48 +00:00
- `noazblob` , disable Azure Blob Storage backend, default enabled
2020-06-19 15:08:51 +00:00
- `nobolt` , disable Bolt data provider, default enabled
2020-05-23 10:47:44 +00:00
- `nomysql` , disable MySQL data provider, default enabled
- `nopgsql` , disable PostgreSQL data provider, default enabled
- `nosqlite` , disable SQLite data provider, default enabled
- `noportable` , disable portable mode, default enabled
2020-06-19 15:08:51 +00:00
- `nometrics` , disable Prometheus metrics, default enabled
2022-07-24 18:02:37 +00:00
- `bundle` , embed static files and templates. Before building with this tag enabled you have to copy `openapi` , `static` and `templates` dirs to `internal/bundle` directory. Default disabled
2023-03-26 08:33:30 +00:00
- `unixcrypt` , enable linking to `libcrypt` , default disabled, requires `CGO`
2020-05-23 09:58:05 +00:00
2020-05-23 10:47:44 +00:00
If no build tag is specified the build will include the default features.
2020-05-23 09:58:05 +00:00
The optional [SQLite driver ](https://github.com/mattn/go-sqlite3 "go-sqlite3" ) is a `CGO` package and so it requires a `C` compiler at build time.
2020-03-04 22:10:58 +00:00
On Linux and macOS, a compiler is easy to install or already installed. On Windows, you need to download [MinGW-w64 ](https://sourceforge.net/projects/mingw-w64/files/ ) and build SFTPGo from its command prompt.
The compiler is a build time only dependency. It is not required at runtime.
Version info, such as git commit and build date, can be embedded setting the following string variables at build time:
2022-07-24 14:18:54 +00:00
- `github.com/drakkan/sftpgo/v2/internal/version.commit`
- `github.com/drakkan/sftpgo/v2/internal/version.date`
2020-03-04 22:10:58 +00:00
For example, you can build using the following command:
```bash
2022-09-08 11:44:14 +00:00
go build -tags nogcs,nos3,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
2020-03-04 22:10:58 +00:00
```
2020-05-23 09:58:05 +00:00
You should get a version that includes git commit, build date and available features like this one:
2020-03-04 22:10:58 +00:00
```bash
2020-05-23 09:58:05 +00:00
$ ./sftpgo -v
2022-07-24 18:02:37 +00:00
SFTPGo 2.3.1-dev-c8158e1-2022-07-24T17:25:45Z +metrics +azblob +gcs +s3 +bolt +mysql +pgsql +sqlite +portable
2020-06-15 21:46:11 +00:00
```