FROM archlinux
LABEL maintiner="Mark <mark@betalupi.com>"

# Create users and groups.
# Make sure uids and gids are the same on the host!
#
# Syncthing should be installed AFTER users are created.
# The package will create its own syncthing user if one does not exist.
# We need to do it manually, to control uid and gid.

ARG ST_GID="1000"
ARG ST_UID="1000"

RUN groupadd -g ${ST_GID} syncthing && \
	useradd -g ${ST_GID} -u ${ST_UID} syncthing -d /stdata && \
	pacman -Fyy --noconfirm && \
	pacman -Syu --noconfirm && \
	pacman -S --noconfirm syncthing syncthing-relaysrv

RUN mkdir /stdata && \
	mkdir /stconfig && \
	mkdir /stconfig/config && \
	chown -R syncthing:syncthing /stdata && \
	chmod -R 774 /stdata && \
	chown -R syncthing:syncthing /stconfig && \
	chmod -R 774 /stconfig
VOLUME /stdata
VOLUME /stconfig


# Syncthing
EXPOSE 8384
# Relay
EXPOSE 22067


USER ${ST_UID}
WORKDIR "/stdata"

ENTRYPOINT ["/bin/bash", "start.sh"]
