diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b266e80 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +API_URL="https://admin.topwr.solvro.pl/graphql" +ASSETS_URL="https://admin.topwr.solvro.pl/assets" +IPARKING_URL="https://iparking.pwr.edu.pl" +FIREBASE_NAME="CHANGE_ME" +FIREBASE_CLIENT_ID="CHANGE_ME" +FIREBASE_PRIVATE_KEY="CHANGE_ME" +FIREBASE_EMAIL="CHANGE_ME" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3948a1d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy + +on: + push: + branches: ["main"] + +env: + REGISTRY: ghcr.io + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Add envs + run: cp .env.example .env + + - name: Add firebase config + run: | + echo "${{ secrets.FIREBASE_CONFIG }}" | base64 --decode > lib/firebase_options.dart + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ghcr.io/solvro/web-topwr-sci-clubs-form:latest + cache-from: type=registry,ref=ghcr.io/solvro/web-topwr-sci-clubs-form:latest + cache-to: type=inline + network: host + + - name: Trigger build + run: | + curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' diff --git a/.github/workflows/lint_and_format.yml b/.github/workflows/lint_and_format.yml index aadaed0..db0f38c 100644 --- a/.github/workflows/lint_and_format.yml +++ b/.github/workflows/lint_and_format.yml @@ -2,9 +2,7 @@ name: Lint & formatting on: push: - branches: ["**"] pull_request: - branches: ["**"] jobs: build: @@ -17,12 +15,16 @@ jobs: flutter-version: "3.22.3" channel: "stable" - run: flutter --version - + - name: Install dependencies run: dart pub get - + - name: Example .env - run: cp example.env .env + run: cp .env.example .env + + - name: Add firebase config + run: | + echo "${{ secrets.FIREBASE_CONFIG }}" | base64 --decode > lib/firebase_options.dart - name: generate files run: dart run build_runner build --delete-conflicting-outputs @@ -31,4 +33,4 @@ jobs: run: dart format --output=none --set-exit-if-changed . - name: Analyze project source - run: flutter analyze --fatal-infos \ No newline at end of file + run: flutter analyze --fatal-infos diff --git a/.gitignore b/.gitignore index f424d97..df9fde9 100644 --- a/.gitignore +++ b/.gitignore @@ -152,6 +152,7 @@ app.*.symbols .env *.env.dev .env.dev +!.env.example env.g.dart **/env.g.dart diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7b55b2e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Install Operating system and dependencies +FROM ubuntu:20.04 AS build + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update +RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3 +RUN apt-get clean + +ENV DEBIAN_FRONTEND=dialog + +# download Flutter SDK from Flutter Github repo +RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter + +# Set flutter environment path +ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}" + +# Run flutter doctor +RUN flutter doctor + +# Enable flutter web +RUN flutter channel stable +RUN flutter upgrade +RUN flutter config --enable-web + +# Copy files to container and build +RUN mkdir /app/ +COPY . /app/ +WORKDIR /app/ +RUN dart run build_runner build -d +RUN flutter build web --web-renderer html + +FROM socialengine/nginx-spa:latest +COPY --chown=nginx:nginx --from=build /app/build/web /app +EXPOSE 80 diff --git a/lib/config/api_base_config.dart b/lib/config/api_base_config.dart index e20eb36..3fc4012 100644 --- a/lib/config/api_base_config.dart +++ b/lib/config/api_base_config.dart @@ -12,7 +12,7 @@ abstract class ApiBaseConfig { path: ".env", obfuscate: true, useConstantCase: true, - requireEnvFile: true, + requireEnvFile: false, ) abstract class ApiBaseEnv { @EnviedField()