mirror of
https://github.com/gogs/gogs.git
synced 2025-05-21 06:50:40 +00:00
build: remove Makefile and update Docker build steps (#6980)
This commit is contained in:
parent
8356dc7774
commit
d7bda9ac0e
@ -4,7 +4,6 @@ scripts
|
|||||||
scripts/**
|
scripts/**
|
||||||
.github/
|
.github/
|
||||||
.github/**
|
.github/**
|
||||||
config.codekit
|
|
||||||
.dockerignore
|
.dockerignore
|
||||||
*.yml
|
*.yml
|
||||||
*.md
|
*.md
|
||||||
@ -12,3 +11,5 @@ config.codekit
|
|||||||
.gitignore
|
.gitignore
|
||||||
Dockerfile*
|
Dockerfile*
|
||||||
gogs
|
gogs
|
||||||
|
|
||||||
|
!Taskfile.yml
|
||||||
|
@ -17,7 +17,7 @@ All notable changes to Gogs are documented in this file.
|
|||||||
|
|
||||||
- The default branch has been changed to `main`. [#6285](https://github.com/gogs/gogs/pull/6285)
|
- The default branch has been changed to `main`. [#6285](https://github.com/gogs/gogs/pull/6285)
|
||||||
- MSSQL as database backend is deprecated, installation page no longer shows it as an option. Existing installations and manually craft configuration file continue to work. [#6295](https://github.com/gogs/gogs/pull/6295)
|
- MSSQL as database backend is deprecated, installation page no longer shows it as an option. Existing installations and manually craft configuration file continue to work. [#6295](https://github.com/gogs/gogs/pull/6295)
|
||||||
- Use [Task](https://github.com/go-task/task) as the default build tool for development. [#6297](https://github.com/gogs/gogs/pull/6297)
|
- Use [Task](https://github.com/go-task/task) as the build tool. [#6297](https://github.com/gogs/gogs/pull/6297)
|
||||||
- The required Go version to compile source code changed to 1.16.
|
- The required Go version to compile source code changed to 1.16.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@ -42,6 +42,7 @@ All notable changes to Gogs are documented in this file.
|
|||||||
- Configuration option `[server] LANDING_PAGE` is no longer used, please use `[server] LANDING_URL`.
|
- Configuration option `[server] LANDING_PAGE` is no longer used, please use `[server] LANDING_URL`.
|
||||||
- Configuration option `[database] DB_TYPE` is no longer used, please use `[database] TYPE`.
|
- Configuration option `[database] DB_TYPE` is no longer used, please use `[database] TYPE`.
|
||||||
- Configuration option `[database] PASSWD` is no longer used, please use `[database] PASSWORD`.
|
- Configuration option `[database] PASSWD` is no longer used, please use `[database] PASSWORD`.
|
||||||
|
- Remove option to use Makefile as the build tool. [#6980](https://github.com/gogs/gogs/pull/6980)
|
||||||
|
|
||||||
## 0.12.7
|
## 0.12.7
|
||||||
|
|
||||||
|
18
Dockerfile
18
Dockerfile
@ -7,20 +7,12 @@ RUN apk --no-cache --no-progress add --virtual \
|
|||||||
|
|
||||||
WORKDIR /gogs.io/gogs
|
WORKDIR /gogs.io/gogs
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make build TAGS="cert pam"
|
|
||||||
|
RUN ./docker/build/install-task.sh
|
||||||
|
RUN TAGS="cert pam" task build
|
||||||
|
|
||||||
FROM alpine:3.14
|
FROM alpine:3.14
|
||||||
RUN if [ `uname -m` == "aarch64" ] ; then \
|
RUN apk --no-cache --no-progress add \
|
||||||
export arch="arm64" ; \
|
|
||||||
elif [ `uname -m` == "armv7l" ] ; then \
|
|
||||||
export arch="armhf"; \
|
|
||||||
else \
|
|
||||||
export arch="amd64" ; \
|
|
||||||
fi \
|
|
||||||
&& wget https://github.com/tianon/gosu/releases/download/1.11/gosu-$arch -O /usr/sbin/gosu \
|
|
||||||
&& chmod +x /usr/sbin/gosu \
|
|
||||||
&& echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \
|
|
||||||
&& apk --no-cache --no-progress add \
|
|
||||||
bash \
|
bash \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
@ -42,7 +34,7 @@ WORKDIR /app/gogs
|
|||||||
COPY docker ./docker
|
COPY docker ./docker
|
||||||
COPY --from=binarybuilder /gogs.io/gogs/gogs .
|
COPY --from=binarybuilder /gogs.io/gogs/gogs .
|
||||||
|
|
||||||
RUN ./docker/finalize.sh
|
RUN ./docker/build/finalize.sh
|
||||||
|
|
||||||
# Configure Docker Container
|
# Configure Docker Container
|
||||||
VOLUME ["/data", "/backup"]
|
VOLUME ["/data", "/backup"]
|
||||||
|
59
Makefile
59
Makefile
@ -1,59 +0,0 @@
|
|||||||
LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
|
|
||||||
LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildCommit=$(shell git rev-parse HEAD)"
|
|
||||||
|
|
||||||
CONF_FILES := $(shell find conf | sed 's/ /\\ /g')
|
|
||||||
TEMPLATES_FILES := $(shell find templates | sed 's/ /\\ /g')
|
|
||||||
PUBLIC_FILES := $(shell find public | sed 's/ /\\ /g')
|
|
||||||
LESS_FILES := $(wildcard public/less/*.less)
|
|
||||||
|
|
||||||
TAGS = ""
|
|
||||||
BUILD_FLAGS = "-v"
|
|
||||||
|
|
||||||
RELEASE_ROOT = "release"
|
|
||||||
RELEASE_GOGS = "release/gogs"
|
|
||||||
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
|
||||||
|
|
||||||
.PHONY: check dist build build-no-gen pack release generate less clean test fixme todo legacy
|
|
||||||
|
|
||||||
.IGNORE: public/css/gogs.css
|
|
||||||
|
|
||||||
all: build
|
|
||||||
|
|
||||||
check: test
|
|
||||||
|
|
||||||
dist: release
|
|
||||||
|
|
||||||
web: build
|
|
||||||
./gogs web
|
|
||||||
|
|
||||||
build:
|
|
||||||
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs
|
|
||||||
|
|
||||||
pack:
|
|
||||||
rm -rf $(RELEASE_GOGS)
|
|
||||||
mkdir -p $(RELEASE_GOGS)
|
|
||||||
cp -r gogs LICENSE README.md README_ZH.md scripts $(RELEASE_GOGS)
|
|
||||||
cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs"
|
|
||||||
|
|
||||||
release: build pack
|
|
||||||
|
|
||||||
less: clean public/css/gogs.min.css
|
|
||||||
|
|
||||||
public/css/gogs.min.css: $(LESS_FILES)
|
|
||||||
@type lessc >/dev/null 2>&1 && lessc --clean-css --source-map "public/less/gogs.less" $@ || echo "lessc command not found or failed"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
find . -name "*.DS_Store" -type f -delete
|
|
||||||
|
|
||||||
test:
|
|
||||||
go test -cover -race ./...
|
|
||||||
|
|
||||||
fixme:
|
|
||||||
grep -rnw "FIXME" internal
|
|
||||||
|
|
||||||
todo:
|
|
||||||
grep -rnw "TODO" internal
|
|
||||||
|
|
||||||
# Legacy code should be removed by the time of release
|
|
||||||
legacy:
|
|
||||||
grep -rnw "\(LEGACY\|Deprecated\)" internal
|
|
@ -61,7 +61,7 @@ $ docker run --name=gogs -p 10022:22 -p 10880:3000 -v gogs-data:/data gogs/gogs
|
|||||||
Most of the settings are obvious and easy to understand, but there are some settings can be confusing by running Gogs inside Docker:
|
Most of the settings are obvious and easy to understand, but there are some settings can be confusing by running Gogs inside Docker:
|
||||||
|
|
||||||
- **Repository Root Path**: keep it as default value `/home/git/gogs-repositories` because `start.sh` already made a symbolic link for you.
|
- **Repository Root Path**: keep it as default value `/home/git/gogs-repositories` because `start.sh` already made a symbolic link for you.
|
||||||
- **Run User**: keep it as default value `git` because `finalize.sh` already setup a user with name `git`.
|
- **Run User**: keep it as default value `git` because `build/finalize.sh` already setup a user with name `git`.
|
||||||
- **Domain**: fill in with Docker container IP (e.g. `192.168.99.100`). But if you want to access your Gogs instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine.
|
- **Domain**: fill in with Docker container IP (e.g. `192.168.99.100`). But if you want to access your Gogs instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine.
|
||||||
- **SSH Port**: Use the exposed port from Docker container. For example, your SSH server listens on `22` inside Docker, **but** you expose it by `10022:22`, then use `10022` for this value. **Builtin SSH server is not recommended inside Docker Container**
|
- **SSH Port**: Use the exposed port from Docker container. For example, your SSH server listens on `22` inside Docker, **but** you expose it by `10022:22`, then use `10022` for this value. **Builtin SSH server is not recommended inside Docker Container**
|
||||||
- **HTTP Port**: Use port you want Gogs to listen on inside Docker container. For example, your Gogs listens on `3000` inside Docker, **and** you expose it by `10880:3000`, but you still use `3000` for this value.
|
- **HTTP Port**: Use port you want Gogs to listen on inside Docker container. For example, your Gogs listens on `3000` inside Docker, **and** you expose it by `10880:3000`, but you still use `3000` for this value.
|
||||||
|
30
docker/build/finalize.sh
Executable file
30
docker/build/finalize.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
# Install gosu
|
||||||
|
if [ "$(uname -m)" = "aarch64" ]; then
|
||||||
|
export arch='arm64'
|
||||||
|
export checksum='73244a858f5514a927a0f2510d533b4b57169b64d2aa3f9d98d92a7a7df80cea'
|
||||||
|
elif [ "$(uname -m)" = "armv7l" ]; then
|
||||||
|
export arch='armhf'
|
||||||
|
export checksum='abb1489357358b443789571d52b5410258ddaca525ee7ac3ba0dd91d34484589'
|
||||||
|
else
|
||||||
|
export arch='amd64'
|
||||||
|
export checksum='bd8be776e97ec2b911190a82d9ab3fa6c013ae6d3121eea3d0bfd5c82a0eaf8c'
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget --quiet https://github.com/tianon/gosu/releases/download/1.14/gosu-${arch} -O /usr/sbin/gosu
|
||||||
|
echo "${checksum} /usr/sbin/gosu" | sha256sum -cs
|
||||||
|
chmod +x /usr/sbin/gosu
|
||||||
|
|
||||||
|
# Create git user for Gogs
|
||||||
|
addgroup -S git
|
||||||
|
adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && usermod -p '*' git && passwd -u git
|
||||||
|
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
|
||||||
|
|
||||||
|
# Final cleaning
|
||||||
|
rm -rf /app/gogs/build
|
||||||
|
rm -rf /app/gogs/docker/build
|
||||||
|
rm /app/gogs/docker/nsswitch.conf
|
||||||
|
rm /app/gogs/docker/README.md
|
20
docker/build/install-task.sh
Executable file
20
docker/build/install-task.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
if [ "$(uname -m)" = "aarch64" ]; then
|
||||||
|
export arch='arm64'
|
||||||
|
export checksum='44fad3d61ad39d0abff33f90fdbb99a666524dbeab08dc9d138d5d3a532ff68a'
|
||||||
|
elif [ "$(uname -m)" = "armv7l" ]; then
|
||||||
|
export arch='arm'
|
||||||
|
export checksum='b10ae7d85749025740097b0c349b946fbabd417c7ee4d2df8ccc5604750accd9'
|
||||||
|
else
|
||||||
|
export arch='amd64'
|
||||||
|
export checksum='b9c5986f33a53094751b5e22ccc33e050b4a0a485658442121331cbb724e631e'
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget --quiet https://github.com/go-task/task/releases/download/v3.12.1/task_linux_${arch}.tar.gz -O task_linux_${arch}.tar.gz
|
||||||
|
echo "${checksum} task_linux_${arch}.tar.gz" | sha256sum -cs
|
||||||
|
|
||||||
|
tar -xzf task_linux_${arch}.tar.gz
|
||||||
|
mv task /usr/local/bin/task
|
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# Finalize the build
|
|
||||||
|
|
||||||
set -x
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Create git user for Gogs
|
|
||||||
addgroup -S git
|
|
||||||
adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && usermod -p '*' git && passwd -u git
|
|
||||||
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
|
|
||||||
|
|
||||||
# Final cleaning
|
|
||||||
rm -rf /app/gogs/build
|
|
||||||
rm /app/gogs/docker/finalize.sh
|
|
||||||
rm /app/gogs/docker/nsswitch.conf
|
|
||||||
rm /app/gogs/docker/README.md
|
|
Loading…
x
Reference in New Issue
Block a user