diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 398c8cc..0000000 --- a/.drone.yml +++ /dev/null @@ -1,29 +0,0 @@ -kind: pipeline -name: default - -steps: - - name: dco - group: meta - image: algernon/drone-plugin-dco - - - name: signature-check - group: meta - image: algernon/drone-plugin-signature-check - keys: [10E65DC045EABEFCC5193A26AC1E90BAC433F68F] - when: - event: tag - - - name: publish - image: plugins/docker - settings: - repo: algernon/writefreely - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - ref: - include: - - refs/heads/master - - refs/tags/** diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..92b8ef5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,46 @@ + +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registries: + name: Push Docker image to registry + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: | + jrasanen/writefreely + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3050768..73c9773 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -ARG GOLANG_VERSION=1.17 +ARG GOLANG_VERSION=1.18 # Build image FROM golang:${GOLANG_VERSION}-alpine as build diff --git a/bin/writefreely-docker.sh b/bin/writefreely-docker.sh index b7cfe06..21079ac 100755 --- a/bin/writefreely-docker.sh +++ b/bin/writefreely-docker.sh @@ -21,36 +21,15 @@ cd /data WRITEFREELY=/writefreely/writefreely -if [ -e ./config.ini ] && [ -e ./writefreely.db ] && [ -e ./keys/email.aes256 ]; then - BACKUP="writefreely.$(date +%s).db" - cp writefreely.db ${BACKUP} +if [ -e ./config.ini ] && [ -e ./keys/email.aes256 ]; then ${WRITEFREELY} -migrate - if cmp writefreely.db ${BACKUP}; then - rm ${BACKUP} - else - echo "Database backed up at /data/${BACKUP}" - fi exec ${WRITEFREELY} fi if [ -e ./config.ini ]; then - if [ ! -s ./writefreely.db ]; then - ${WRITEFREELY} -init-db - fi - if [ ! -e ./keys/email.aes256 ]; then - ${WRITEFREELY} -gen-keys - fi - - BACKUP="writefreely.$(date +%s).db" - cp writefreely.db ${BACKUP} - ${WRITEFREELY} -migrate - if cmp writefreely.db ${BACKUP}; then - rm ${BACKUP} - else - echo "Database backed up at /data/${BACKUP}" - fi + ${WRITEFREELY} -init-db + ${WRITEFREELY} -gen-keys exec ${WRITEFREELY} - fi WRITEFREELY_BIND_PORT="${WRITEFREELY_BIND_PORT:-8080}" @@ -70,17 +49,16 @@ pages_parent_dir = /writefreely keys_parent_dir = [database] -type = sqlite3 -filename = writefreely.db -username = -password = -database = -host = localhost +type = mysql +username = ${WRITEFREELY_DATABASE_USERNAME} +password = ${WRITEFREELY_DATABASE_PASSWORD} +database = ${WRITEFREELY_DATABASE_NAME} +host = ${WRITEFREELY_DATABASE_HOST} port = 3306 [app] site_name = ${WRITEFREELY_SITE_NAME} -site_description = +site_description = host = ${WRITEFREELY_HOST:-http://${WRITEFREELY_BIND_HOST}:${WRITEFREELY_BIND_PORT}} theme = write disable_js = false