-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Olaf Leidinger
committed
Jun 22, 2019
1 parent
034cea8
commit b6016a5
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Two-staged build | ||
# 1. Use a container with rust to build the executable | ||
# 2. Copy the executable from that container to actual one. | ||
# | ||
# alpine is used, since it's small. | ||
# alpine/edge is used, since it's flatpak and rust are modern. | ||
|
||
FROM alpine:edge AS builder | ||
WORKDIR /root | ||
RUN apk add cargo rust | ||
RUN apk add postgresql-dev | ||
RUN cargo --quiet install --git https://github.com/flatpak/flat-manager.git --tag 0.3.4 --root=/root | ||
RUN cd /root/.cargo/git/checkouts/flat-manager*/* && \ | ||
install -m 755 -D -t /root/bin flat-manager-client && \ | ||
install -m 644 -D -t /root/etc example-config.json | ||
|
||
################################################################################# | ||
|
||
FROM alpine:edge | ||
|
||
# Run time dependencies | ||
RUN apk add libpq # postgres runtime dependency | ||
RUN apk add flatpak | ||
|
||
# Copy the executable(s) from builder | ||
COPY --from=builder /root/bin/ /usr/bin | ||
COPY --from=builder /root/etc /etc/flat-manager | ||
|
||
|
||
# A setup script | ||
ADD entrypoint.sh /usr/bin | ||
RUN chown root:root /usr/bin/entrypoint.sh && chmod 755 /usr/bin/entrypoint.sh | ||
|
||
# Create needed directories | ||
RUN mkdir -p /var/run/postgresql | ||
|
||
ENV HOME /var/run/flat-manager | ||
ENV REPO_CONFIG $HOME/config.json | ||
ENV RUST_LOG info | ||
|
||
# Add a user | ||
RUN addgroup flatmanager &&\ | ||
adduser -D -G flatmanager -h $HOME -s /sbin/nologin flatmanager | ||
|
||
USER flatmanager | ||
# from default config; may change, if config changes | ||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/usr/bin/entrypoint.sh"] | ||
CMD ["flat-manager"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Forewords | ||
|
||
In this simple setup, both flat-manager and postgres are alpine based to keep things small. | ||
A socket is shared between the containers for simplicity. This, however, won't work across machines. | ||
|
||
# Set up storage | ||
POSTGRES_RUNDIR=/path/to/some/storage/postgres-run | ||
POSTGRES_DB=/path/to/some/storage/postgres-db | ||
FLATMAN_REPO=/path/to/some/storage/flatman-repo | ||
|
||
mkdir -p $POSTGRES_RUNDIR | ||
mkdir -p $POSTGRES_DB | ||
mkdir -p $FLATMAN_REPO | ||
|
||
# Run postgres in one terminal | ||
docker run --rm \ | ||
-v $POSTGRES_RUNDIR:/var/run/postgresql \ | ||
-e POSTGRES_PASSWORD=mysecretpasspassword \ | ||
-e POSTGRES_USER=flatmanager \ | ||
-e POSTGRES_DB=repo \ | ||
--name flat-manager-postgres postgres:alpine | ||
|
||
# Flat-manager | ||
## Build docker image | ||
docker build --tag yourname/flat-manager:latest . | ||
## Run image | ||
docker run --rm \ | ||
-v $FLATMAN_REPO:/var/run/flat-manager \ | ||
-v $POSTGRES_RUNDIR:/var/run/postgresql \ | ||
-p 8080:8080 yourname/flat-manager:latest | ||
|
||
At this point, you'll need to stop the container again and edit `$FLATMAN_REPO/config.js`. This is the unmodified default config. It would seem you need to tell `flat-manager` to listen on all interfaces to make forwarding work, namely: | ||
|
||
```json | ||
"host": "0.0.0.0", | ||
``` | ||
|
||
When running `yourname/flat-manager:latest` again, you should be able to access http://localhost:8080/status from your browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -f $REPO_CONFIG ]; then | ||
echo No config found, copying example config. | ||
cp /etc/flat-manager/example-config.json "$REPO_CONFIG" | ||
fi | ||
|
||
exec $* |