Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically refresh upstream and create Docker image #541

Open
wants to merge 76 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
21b721e
feat: add sync-upstream.yaml
May 2, 2024
0f58f34
feat: add docker.yaml
May 2, 2024
f3823f0
feat: add first docker-compose.yaml
May 7, 2024
32e7d5f
feat: add workflow_dispatch: to docker.yaml
May 13, 2024
40841a6
feat: add ftcli db upgrade to docker-compose.yaml
May 14, 2024
cab78d6
feat: add alpine based for images
May 15, 2024
7cfcdb1
feat: add sync-merge.yaml
May 16, 2024
113cd01
delete sync-upstream.yaml
May 16, 2024
6e766f1
Merge remote-tracking branch 'upstream/master'
DavidHenryThoreau May 16, 2024
77c4d7d
add postgres:13 to docker-compose.yaml
May 16, 2024
4e0f95b
feat: add --no-cache to Dockerfile
May 16, 2024
14aa135
feat: add cron job to build every day image
DavidHenryThoreau May 23, 2024
1da133e
add restart: unless-stopped to docker-compose.yaml
May 17, 2024
54bd086
docker-compose.yaml: removed empty variables
DavidHenryThoreau May 17, 2024
2b1d1a7
add redis depends
DavidHenryThoreau May 17, 2024
5e08e8e
Update README.md
SamR1 May 18, 2024
1bc5822
Translated using Weblate (Czech)
jmlich May 11, 2024
ab14936
Translated using Weblate (Czech)
jmlich May 12, 2024
35fbcdf
Translated using Weblate (Czech)
jmlich May 11, 2024
1a94d1b
Translated using Weblate (Czech)
jmlich May 12, 2024
00e9a82
Translated using Weblate (Czech)
jmlich May 11, 2024
5886914
Translated using Weblate (Czech)
jmlich May 12, 2024
720d9b9
Client - fix typo in 'en' translations
SamR1 May 12, 2024
3876613
build dist files
SamR1 May 12, 2024
3d6770c
Translated using Weblate (Czech)
jmlich May 16, 2024
5c2087f
Translated using Weblate (Czech)
jmlich May 16, 2024
3cd3856
Translated using Weblate (Czech)
jmlich May 16, 2024
c4fe0e9
Translated using Weblate (Czech)
jmlich May 16, 2024
905d82a
Translated using Weblate (Czech)
jmlich May 16, 2024
923b799
Translated using Weblate (Czech)
jmlich May 16, 2024
339bc24
API - remove unneeded code
SamR1 May 18, 2024
128fd4e
API - update query to get records
SamR1 May 18, 2024
8b64d77
API - minor test fixtures refacto
SamR1 May 18, 2024
289fe59
API - enable future flag on engine during db initialization
SamR1 May 18, 2024
c8b6825
API - enable future flag on session during db initialization
SamR1 May 18, 2024
3efc031
API - init Portuguese (pt) translation files for emails
SamR1 May 20, 2024
51a9e4b
Client - init Portuguese (pt) translation files
SamR1 May 20, 2024
d240155
build dist files
SamR1 May 20, 2024
1e06921
Makefile - update lint-python-fix command
SamR1 May 20, 2024
9f38037
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
d430943
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
54c7f65
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
ea41a8f
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
f8d30db
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
72c7046
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
893d0ad
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
6323625
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
9ecc8b3
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
63bc73d
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
b54560f
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
6a8b5c9
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
3713313
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
7a8515c
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
cbde334
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
cfd8aeb
Translated using Weblate (Portuguese)
voodoopt May 20, 2024
e43b26f
API & Client - enable pt translations
SamR1 May 20, 2024
a5e2634
Client - fix pt translations
SamR1 May 20, 2024
887aef8
build dist files
SamR1 May 20, 2024
cf0aa9d
update python deps
SamR1 May 22, 2024
bf140ff
update js deps
SamR1 May 22, 2024
21d74dc
build dist files
SamR1 May 22, 2024
a83f2bc
Client - translation fix
SamR1 May 22, 2024
164b80b
Client - add password strength estimation for Czech
SamR1 May 22, 2024
fc35fbf
build dist files
SamR1 May 22, 2024
6e00102
CLI - init language preference on user creation
SamR1 May 22, 2024
40e47ea
CLI - fix tokens tokens cleaning
SamR1 May 22, 2024
53cfef0
bump to 0.8.4
SamR1 May 22, 2024
04c39a1
feat: remove tag v* and cron to docker.yaml
DavidHenryThoreau May 27, 2024
ab5c884
feat: add --tags to fetch tags
DavidHenryThoreau May 28, 2024
a535066
Merge remote-tracking branch 'upstream/master'
DavidHenryThoreau May 28, 2024
1e93e75
feat: --all to fetch tags
DavidHenryThoreau May 27, 2024
990752d
feat: add --tags
DavidHenryThoreau May 28, 2024
b064818
feat: add tags: [v*]
DavidHenryThoreau May 28, 2024
5b28842
feat: add PostgreSQL 16 and Python 3.12
DavidHenryThoreau May 31, 2024
e8d5dd3
feat: wget latest.zip reduced size
DavidHenryThoreau Jun 3, 2024
0d88540
feat: add user fittrackee to Dockerfile
DavidHenryThoreau Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: ["master"]
tags: ["v*"]
workflow_dispatch:

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=release
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
build-args: |
BUILD_TIME=${{ env.BUILD_TIME }}
GIT_COMMIT=${{ github.sha }}
GIT_REF=${{ github.ref }}
GIT_REF_NAME=${{ github.ref_name }}
GIT_REF_TYPE=${{ github.ref_type }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
44 changes: 44 additions & 0 deletions .github/workflows/sync-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Sync Upstream

env:
# Required, URL to upstream (fork base)
UPSTREAM_URL: "https://github.com/SamR1/FitTrackee.git"
# Required, token to authenticate bot, could use ${{ secrets.GITHUB_TOKEN }}
# Over here, we use a PAT instead to authenticate workflow file changes.
#WORKFLOW_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Optional, defaults to master
UPSTREAM_BRANCH: "master"
# Optional, defaults to UPSTREAM_BRANCH
DOWNSTREAM_BRANCH: ""
# Optional fetch arguments
FETCH_ARGS: "--tags"
# Optional merge arguments
MERGE_ARGS: ""
# Optional push arguments
PUSH_ARGS: "--tags"
# Optional toggle to spawn time logs (keeps action active)
SPAWN_LOGS: "false" # "true" or "false"

# This runs every day on 1801 UTC
on:
schedule:
- cron: '0 22 * * *'
# Allows manual workflow run (must in default branch to work)
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: GitHub Sync to Upstream Repository
uses: dabreadman/sync-upstream-repo@v1.3.0
with:
upstream_repo: ${{ env.UPSTREAM_URL }}
upstream_branch: ${{ env.UPSTREAM_BRANCH }}
downstream_branch: ${{ env.DOWNSTREAM_BRANCH }}
token: ${{ env.WORKFLOW_TOKEN }}
fetch_args: ${{ env.FETCH_ARGS }}
merge_args: ${{ env.MERGE_ARGS }}
push_args: ${{ env.PUSH_ARGS }}
spawn_logs: ${{ env.SPAWN_LOGS }}
40 changes: 31 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
FROM python:3.10
FROM python:3.12-alpine

# set working directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# install dependencies
RUN apk add --no-cache linux-headers gcc musl-dev libffi-dev \
--virtual=build-dependencies
RUN apk add --no-cache py-pip bash curl

# create user fittrackee
RUN addgroup -g 1000 -S fittrackee
RUN adduser -u 1000 -S -D -G fittrackee -H -h /usr/src/app -s /bin/bash fittrackee

# copy source files
COPY . /usr/src/app
RUN LATEST=$(curl -s \
"https://api.github.com/repos/SamR1/FitTrackee/releases/latest" | \
grep -i zipball_url | grep -Eo "https://.*[0-9]{1}") && \
wget "${LATEST}" -O /usr/src/latest.zip
RUN cd /usr/src/ && unzip latest.zip -d /usr/src/app
RUN sync
RUN mv /usr/src/app/*FitTrackee*/* /usr/src/app/
RUN rm -r /usr/src/app/*FitTrackee*/
RUN rm -r /usr/src/latest.zip

# install requirements
WORKDIR /usr/src/app
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
RUN pip install poetry
RUN . $VIRTUAL_ENV/bin/activate && poetry install --no-interaction --quiet
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir poetry
RUN . $VIRTUAL_ENV/bin/activate && poetry install --no-interaction

# change owner
RUN chown -R fittrackee:fittrackee /usr/src/app

# delete build packages
RUN apk del --purge build-dependencies
RUN rm -r /root/.cache

# run fittrackee server
CMD flask run --with-threads -h 0.0.0.0
USER fittrackee
CMD flask run --with-threads -h 0.0.0.0
56 changes: 56 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
version: "3.1"
services:
fittrackee:
image: ghcr.io/davidhenrythoreau/fittrackee:master
container_name: fittrackee
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Paris
- FLASK_DEBUG=1
- FLASK_APP=fittrackee/__main__.py
- FLASK_SKIP_DOTENV=1
- APP_SETTINGS=fittrackee.config.DevelopmentConfig
- APP_SECRET_KEY='just for test'
- APP_LOG=fittrackee.log
- UPLOAD_FOLDER=/usr/src/app/uploads
- DATABASE_URL=postgresql://fittrackee:fittrackee@fittrackee-db:5432/fittrackee
- DATABASE_TEST_URL=postgresql://fittrackee:fittrackee@fittrackee-db:5432/fittrackee_test
- REDIS_URL=redis://fittrackee-redis:6379
ports:
- 8230:5000
depends_on:
fittrackee-db:
condition: service_started
fittrackee-redis:
condition: service_started
command: bash -c "cd /usr/src/app && ftcli db upgrade && flask run --with-threads -h 0.0.0.0"
restart: unless-stopped

fittrackee-db:
image: postgres:16-alpine
container_name: fittrackee-db
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Paris
- POSTGRES_USER=fittrackee
- POSTGRES_PASSWORD=fittrackee
- POSTGRES_DB=fittrackee
volumes:
- ./fittrackee-db:/var/lib/postgresql/data
ports:
- 5432:5432
restart: unless-stopped

fittrackee-redis:
image: redis:latest
container_name: fittrackee-redis
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Paris
ports:
- 6379:6379
restart: unless-stopped
7 changes: 4 additions & 3 deletions fittrackee_client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18
FROM node:18-alpine

MAINTAINER SamR1@users.noreply.github.com

Expand All @@ -18,7 +18,8 @@ ENV VITE_APP_API_URL $VITE_APP_API_URL
# install dependencies
COPY package.json /usr/src/app/package.json
COPY yarn.lock /usr/src/app/yarn.lock
RUN yarn install --silent
RUN yarn install --silent && yarn cache clean --force
RUN npm run build

# copy source
COPY . /usr/src/app/
COPY . /usr/src/app/