Skip to content

Commit

Permalink
build: remove Makefile and update Docker build steps (#6980)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed May 29, 2022
1 parent 8356dc7 commit d7bda9a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 91 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Expand Up @@ -4,11 +4,12 @@ scripts
scripts/**
.github/
.github/**
config.codekit
.dockerignore
*.yml
*.md
.editorconfig
.gitignore
Dockerfile*
gogs

!Taskfile.yml
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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)
- 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.

### Fixed
Expand All @@ -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 `[database] DB_TYPE` is no longer used, please use `[database] TYPE`.
- 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

Expand Down
18 changes: 5 additions & 13 deletions Dockerfile
Expand Up @@ -7,20 +7,12 @@ RUN apk --no-cache --no-progress add --virtual \

WORKDIR /gogs.io/gogs
COPY . .
RUN make build TAGS="cert pam"

RUN ./docker/build/install-task.sh
RUN TAGS="cert pam" task build

FROM alpine:3.14
RUN if [ `uname -m` == "aarch64" ] ; then \
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 \
RUN apk --no-cache --no-progress add \
bash \
ca-certificates \
curl \
Expand All @@ -42,7 +34,7 @@ WORKDIR /app/gogs
COPY docker ./docker
COPY --from=binarybuilder /gogs.io/gogs/gogs .

RUN ./docker/finalize.sh
RUN ./docker/build/finalize.sh

# Configure Docker Container
VOLUME ["/data", "/backup"]
Expand Down
59 changes: 0 additions & 59 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion docker/README.md
Expand Up @@ -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:

- **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.
- **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.
Expand Down
30 changes: 30 additions & 0 deletions docker/build/finalize.sh
@@ -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 changes: 20 additions & 0 deletions docker/build/install-task.sh
@@ -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
16 changes: 0 additions & 16 deletions docker/finalize.sh

This file was deleted.

0 comments on commit d7bda9a

Please sign in to comment.