Skip to content

Commit

Permalink
Merge pull request #256 from OpenFactorioServerManager/develop
Browse files Browse the repository at this point in the history
Update 0.10.0
  • Loading branch information
knoxfighter authored Feb 10, 2021
2 parents 99e32dd + c75c4e7 commit 2d536d1
Show file tree
Hide file tree
Showing 65 changed files with 1,470 additions and 653 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/create-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-go@v2
- name: Install mingw-w64
run: sudo apt-get update && sudo apt-get install gcc-multilib g++-multilib gcc-mingw-w64 g++-mingw-w64
- name: Get git tag
id: tag_name
uses: little-core-labs/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ jobs:
docker-push:
needs: [test-npm, test-go]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
if: github.event_name == 'push' && github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/[email protected]
- uses: actions/setup-node@v1
- uses: actions/setup-go@v2
- uses: docker/setup-buildx-action@v1
Expand All @@ -78,4 +79,4 @@ jobs:
context: ./docker/
file: ./docker/Dockerfile-local
push: true
tags: ofsm/ofsm:develop
tags: ofsm/ofsm:${{ env.GITHUB_REF_SLUG }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules/
dev/
dev_packs/
/factorio-server-manager*
/factorio_server_manager*
factorio-server-manager*
factorio_server_manager*
auth.leveldb*
conf.json
*.exe
Expand All @@ -18,3 +18,4 @@ mix-manifest.json
/app/*.css*
.vscode
.env
*.db
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [0.10.0] - 2021-02-10
### Added
- Config files can be defined with absolute paths. - Thanks to @FoxAmes
- Support for >= 1.1.14 factorio saves - Thanks to @knoxfighter
- Setting in `info.json` to allow usage without ssl/tls - Thanks to @knoxfighter

### Changed
- Rework of the authentication, to have a bit more security. - Thanks to @knoxfighter
- Changed from leveldb to sqlite3 as backend database. - Thanks to @knoxfighter
- generate new random passwords, if no exist, or if they are "factorio". - Thanks to @knoxfighter
- Use "OpenFactorioServerManager" instead of "mroote" as go package name. - Thanks to @mroote
- Disable mods-page, while server is running - Thanks to @knoxfighter
- Renamed GO-package from `mroote` to `OpenFactorioServerManager` to match git repo - Thanks to @mroote

### Fixed
- old factorio versions depended by mods always shown as compatible - Thanks to @knoxfighter
- Crosscompilation with mingw-w64 on linux. (Broke with sqlite3) - Thanks to @knoxfighter
- Crash on async writing to websocket room array. - Thanks to @knoxfighter

## [0.9.0] - 2021-01-07
### Added
- Autostart factorio, when starting the server-manager - Thanks to @Psychomantis71
Expand All @@ -13,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Rework of the docker image, so it allows easy updating of factorio - Thanks to @ita-sammann

### Fixed
- Console page is now working correctly (directly reloading still bugged until new UI) - Thanks to @jannaahs
- Console page is now working correctly - Thanks to @jannaahs
- Mod Search fixed by new implementation, which does not rely on the search endpoint of the mod portal - Thanks to @jannaahs
- Listen on port 80, previously port 8080 was used. Can be changed with `--port <port>`
- Update version numbers in Docker containers
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build/factorio-server-manager-%.zip: clean app/bundle factorio-server-manager-%
@cp -r app/ factorio-server-manager/
@cp conf.json.example factorio-server-manager/conf.json
@zip -r $@ factorio-server-manager > /dev/null
@rm -r factorio-server-manager/

app/bundle:
@echo "Building Frontend"
Expand All @@ -27,13 +28,13 @@ factorio-server-manager-linux:
@echo "Building Backend - Linux"
@mkdir -p factorio-server-manager
@cd src; \
GO111MODULE=on GOOS=linux GOARCH=amd64 go build -ldflags="-extldflags=-static" -o ../factorio-server-manager/factorio-server-manager .
CGO_ENABLED=1 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -ldflags="-extldflags=-static" -o ../factorio-server-manager/factorio-server-manager .

factorio-server-manager-windows:
@echo "Building Backend - Windows"
@mkdir -p factorio-server-manager
@cd src; \
GO111MODULE=on GOOS=windows GOARCH=386 go build -ldflags="-extldflags=-static" -o ../factorio-server-manager/factorio-server-manager.exe .
GO111MODULE=on GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -ldflags="-extldflags=-static" -o ../factorio-server-manager/factorio-server-manager.exe .

gen_release: build/factorio-server-manager-linux.zip build/factorio-server-manager-windows.zip
@echo "Done"
Expand Down
12 changes: 5 additions & 7 deletions conf.json.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"username": "admin",
"password": "factorio",
"database_file": "auth.leveldb",
"cookie_encryption_key": "topsecretkey",
"settings_file": "server-settings.json",
"log_file": "factorio-server-manager.log",
"rcon_pass": "factorio_rcon"
"rcon_pass": "",
"sq_lite_database_file": "sqlite.db",
"cookie_encryption_key": "",
"settings_file": "server-settings.json",
"log_file": "factorio-server-manager.log"
}
3 changes: 0 additions & 3 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ADMIN_USER=admin
ADMIN_PASS=factorio
RCON_PASS=
COOKIE_ENCRYPTION_KEY=
DOMAIN_NAME=<YOUR DOMAIN NAME>
EMAIL_ADDRESS=<YOUR EMAIL ADDRESS>
7 changes: 2 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
FROM frolvlad/alpine-glibc

ENV FACTORIO_VERSION=stable \
MANAGER_VERSION=0.9.0 \
ADMIN_USER=admin \
ADMIN_PASS=factorio \
RCON_PASS="" \
COOKIE_ENCRYPTION_KEY=""
MANAGER_VERSION=0.10.0 \
RCON_PASS=""

VOLUME /opt/fsm-data /opt/factorio/saves /opt/factorio/mods /opt/factorio/config

Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
FROM alpine:latest as build

RUN apk add --no-cache git make musl-dev go nodejs npm zip
RUN apk add --no-cache git make musl-dev go nodejs npm zip mingw-w64-gcc

ENV FACTORIO_BRANCH=develop
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH
ENV FACTORIO_ROOT /go/src/factorio-server-manager

COPY build-release.sh /usr/local/bin/build-release.sh
COPY docker/build-release.sh /usr/local/bin/build-release.sh
COPY ./ $FACTORIO_ROOT

RUN mkdir -p ${GOPATH}/bin
RUN chmod u+x /usr/local/bin/build-release.sh

WORKDIR $FACTORIO_ROOT

VOLUME /build
VOLUME $FACTORIO_ROOT

RUN ["/usr/local/bin/build-release.sh"]

Expand Down
5 changes: 1 addition & 4 deletions docker/Dockerfile-local
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
FROM frolvlad/alpine-glibc

ENV FACTORIO_VERSION=latest \
ADMIN_USER=admin \
ADMIN_PASS=factorio \
RCON_PASS="" \
COOKIE_ENCRYPTION_KEY=""
RCON_PASS=""

VOLUME /opt/fsm-data /opt/factorio/saves /opt/factorio/mods /opt/factorio/config

Expand Down
24 changes: 11 additions & 13 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ and [Docker Compose](https://docs.docker.com/compose/install/) installed.
Copy `docker-compose.yaml` and `.env` files from this repository to somewhere on your server.

Edit values in the `.env` file:
* `ADMIN_USER` (default `admin`): Name of the default user created for FSM UI.
* `ADMIN_PASS` (default `factorio`): Default user password. \
__Important:__ _For security reasons, please change the default user name and password. Never use the defaults._
* `RCON_PASS` (default empty string): Password for Factorio RCON (FSM uses it to communicate with the Factorio server). \
If left empty, a random password will be generated and saved on the first start of the server. You can see the password in `fsm-data/conf.json` file.
* `COOKIE_ENCRYPTION_KEY` (default empty string): The key used to encrypt auth cookie for FSM UI. \
If left empty, a random key will be generated and saved on the first start of the server. You can see the key in `fsm-data/conf.json` file.
* `DOMAIN_NAME` (must be set manually): The domain name where your FSM UI will be available. Must be set,
so [Let's Encrypt](https://letsencrypt.org/) service can issue a valid HTTPS certificate for this domain.
* `EMAIL_ADDRESS` (must be set manually): Your email address. Used only by Let's Encrypt service.
Expand All @@ -31,7 +26,7 @@ docker-compose up -d

### Simple configuration without HTTPS

If you don't care about HTTPS and want to run just the Factorio Server Manager, or want to run it on local machine you can use `docker-compose.simple.yaml`.
If you don't care about HTTPS and want to run just the Factorio Server Manager, or want to run it on a local machine you can use `docker-compose.simple.yaml`.

Ignore `DOMAIN_NAME` and `EMAIL_ADDREESS` variables in `.env` file and run
```
Expand All @@ -42,15 +37,16 @@ docker-compose -f docker-compose.simple.yaml up -d

By default container will download the latest version of factorio. If you want to use specific version, you can change
the value of `FACTORIO_VERSION=latest` variable in the `docker-compose.yaml` file.
Any version can be used. Using `latest` will download the newest beta version. Using `stable` will download the newest stable version.

## Accessing the application

Go to the domain specified in your `.env` file in your web browser. If running on localhost host access the application at http://localhost
Go to the domain specified in your `.env` file in your web browser. If running on localhost access the application at http://localhost

### First start

When container starts it begins to dowload Factorio headless server archive, and only after that Factorio Server Manager server starts.
So when Docker Compose writes
When container starts it begins to download Factorio headless server archive, and only after that Factorio Server Manager server starts.
So when docker-compose writes
```
Creating factorio-server-manager ... done
```
Expand All @@ -68,7 +64,7 @@ Users can be added and deleted on the settings page.

## Updating Factorio

For now you can't update/downgrade the Factorio version from the UI.
For now, you can't update/downgrade the Factorio version from the UI.

You can however do this using docker images while sustaining your security settings and map/modfiles.

Expand All @@ -80,17 +76,19 @@ After container starts, latest Factorio version will be downloaded and installed

## Security

Authentication is supported in the application but it is recommended to ensure access to the Factorio manager UI is accessible via VPN or internal network.
Authentication is supported in the application, but it is recommended to ensure access to the Factorio manager UI is accessible via VPN or internal network.

## Development
For development purposes it also has the ability to create the docker image from local sourcecode. This is done by running `build.sh` in the `docker` directory. This will delete all old executables and the node_modules directory (runs `make build`). The created docker image will have the tag `factorio-server-manager:dev`.

### Creating release bundles
A Dockerfile-build file is included for creating the release bundles.
A Dockerfile-build file is included for creating the release bundles. Use Docker version 20 in order to use the BUILDKIT environment, some issues have been encountered with Docker version 19.

To create the bundle build the Dockerfile-build file with the following command. The release bundles are output to the ./dist directory.

Run this command from the root factorio-server-manager directory.
```
DOCKER_BUILDKIT=1 docker build --no-cache -f Dockerfile-build -t ofsm-build --target=output -o dist .
DOCKER_BUILDKIT=1 docker build --no-cache -f docker/Dockerfile-build -t ofsm-build --target=build -o dist .
```

## For everyone who actually read this thing to the end
Expand Down
5 changes: 3 additions & 2 deletions docker/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh

echo "Cloning ${FACTORIO_BRANCH}"
git clone -b ${FACTORIO_BRANCH} https://github.com/mroote/factorio-server-manager.git ${FACTORIO_ROOT}
go_version=$(go version)

echo "Go Version: ${go_version}"
echo "Creating build..."
make gen_release
echo "Copying build artifacts from ${PWD}"
Expand Down
4 changes: 1 addition & 3 deletions docker/docker-compose.simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ services:
restart: "unless-stopped"
environment:
- "FACTORIO_VERSION=latest"
- "ADMIN_USER"
- "ADMIN_PASS"
- "RCON_PASS"
- "COOKIE_ENCRYPTION_KEY"
ports:
- "80:80"
- "34197:34197/udp"
Expand All @@ -18,3 +15,4 @@ services:
- "./factorio-data/saves:/opt/factorio/saves"
- "./factorio-data/mods:/opt/factorio/mods"
- "./factorio-data/config:/opt/factorio/config"
- "./factorio-data/mod_packs:/opt/fsm/mod_packs"
4 changes: 1 addition & 3 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ services:
restart: "unless-stopped"
environment:
- "FACTORIO_VERSION=latest"
- "ADMIN_USER"
- "ADMIN_PASS"
- "RCON_PASS"
- "COOKIE_ENCRYPTION_KEY"
volumes:
- "./fsm-data:/opt/fsm-data"
- "./factorio-data/saves:/opt/factorio/saves"
- "./factorio-data/mods:/opt/factorio/mods"
- "./factorio-data/config:/opt/factorio/config"
- "./factorio-data/mod_packs:/opt/fsm/mod_packs"
labels:
- "traefik.enable=true"

Expand Down
26 changes: 5 additions & 21 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,12 @@
init_config() {
jq_cmd='.'

if [ -n $ADMIN_USER ]; then
jq_cmd="${jq_cmd} | .username = \"$ADMIN_USER\""
echo "Admin username is '$ADMIN_USER'"
if [ -n "$RCON_PASS" ]; then
jq_cmd="${jq_cmd} | .rcon_pass = \"$RCON_PASS\""
echo "Factorio rcon password is '$RCON_PASS'"
fi
if [ -n $ADMIN_PASS ]; then
jq_cmd="${jq_cmd} | .password = \"$ADMIN_PASS\""
echo "Admin password is '$ADMIN_PASS'"
fi
echo "IMPORTANT! Please create new user and delete default admin user ASAP."

if [ -z $RCON_PASS ]; then
RCON_PASS="$(random_pass)"
fi
jq_cmd="${jq_cmd} | .rcon_pass = \"$RCON_PASS\""
echo "Factorio rcon password is '$RCON_PASS'"

if [ -z $COOKIE_ENCRYPTION_KEY ]; then
COOKIE_ENCRYPTION_KEY="$(random_pass)"
fi
jq_cmd="${jq_cmd} | .cookie_encryption_key = \"$COOKIE_ENCRYPTION_KEY\""

jq_cmd="${jq_cmd} | .database_file = \"/opt/fsm-data/auth.leveldb\""
jq_cmd="${jq_cmd} | .sq_lite_database_file = \"/opt/fsm-data/sqlite.db\""
jq_cmd="${jq_cmd} | .log_file = \"/opt/fsm-data/factorio-server-manager.log\""

jq "${jq_cmd}" /opt/fsm/conf.json >/opt/fsm-data/conf.json
Expand All @@ -47,5 +31,5 @@ fi

install_game

cd /opt/fsm && ./factorio-server-manager --conf /opt/fsm-data/conf.json --dir /opt/factorio -port 80
cd /opt/fsm && ./factorio-server-manager --conf /opt/fsm-data/conf.json --dir /opt/factorio --port 80

2 changes: 1 addition & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
factorio_username=
factorio_password=
conf=../../conf.json.example
conf=../../conf.json
mod_dir=dev
mod_pack_dir=dev_pack
Loading

0 comments on commit 2d536d1

Please sign in to comment.