Skip to content

Commit

Permalink
chore: updated Dockerfiles to use env variables
Browse files Browse the repository at this point in the history
chore: updated README for better instructions
  • Loading branch information
SethCohen committed Apr 3, 2023
1 parent c817db3 commit d397357
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ firebase_options.dart
google-services.json
GoogleService-Info.plist
src/lib/tests/*
scripts/
scripts/
.env
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Install Operating System
FROM ubuntu:20.04 AS build-env

# Set build arguments
ARG PROJECT_ID
ARG FIREBASE_TOKEN

# Disable interactive mode
ENV DEBIAN_FRONTEND noninteractive

# Prerequisites
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3 sed
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3 sed sudo
RUN apt-get clean

# Download Flutter SDK from Flutter Github repo
Expand All @@ -23,10 +27,20 @@ RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web

# Copy files to container and build
# Copy files to container and set working directory
RUN mkdir /app/
COPY . /app/
WORKDIR /app/src/

# Get Firebase CLI
RUN curl -sL https://firebase.tools | bash

# Setup FlutterFire
RUN dart pub global activate flutterfire_cli
ENV PATH="/root/.pub-cache/bin:${PATH}"
RUN flutterfire configure -t ${FIREBASE_TOKEN} -p ${PROJECT_ID} -y

# Build Flutter Web
RUN flutter build web

# Create the run-time image
Expand Down
59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
# asl
# ASLearner [![Website](https://img.shields.io/website?label=aslearner.apps.science.ontariotechu.ca&style=for-the-badge&url=https%3A%2F%2Faslearner.apps.science.ontariotechu.ca)](https://aslearner.apps.science.ontariotechu.ca/)

An ASL Learning app.
An American Sign Language Learning app.

## How to run project
## Contributing, Selh-Hosting, and Deploying

Debugging: `flutter run -d chrome --web-hostname localhost --web-port 7357`
### Setting everything up

Deploying:
1. [Fork the repository.](https://github.com/SethCohen/ASLearner/fork)
2. [Create and setup your own Firebase project.](https://firebase.google.com/docs/web/setup)
3. Configure Flutter for Firebase Web
1. `$ cd src`
2. `$ firebase login`
3. `$ dart pub global activate flutterfire_cli`
4. [Setup Firestore](https://firebase.google.com/docs/firestore/quickstart) and add some sample data with the following structure.

1. Run `docker build . -t flutter_docker` in terminal.
2. Run `docker run --rm -d -p 7357:80/tcp flutter_docker:latest` in terminal.
1. ```yaml
decks/
<deckId>
cardCount: int
description: string
title: string
cards/
<cardId>
image: string
instructions: string
title: string
type: string="immutable"
users/
```

5. [Setup Google Sign In Web](https://pub.dev/packages/google_sign_in_web#usage)
1. Edit `src/web/index.html` and replace `<meta name="google-signin-client_id" content="YOUR_GOOGLE_SIGN_IN_CLIENT_ID_HERE.apps.googleusercontent.com">`.

### Running the project

#### Debugging

1. `$ flutter run -d chrome --web-hostname localhost --web-port 7357`

#### Deploying using docker

1. Create a `.env` file

```yaml
PROJECT_ID="YOUR_FIREBASE_PROJECT_ID_HERE"
FIREBASE_TOKEN="YOUR_FIREBASE_TOKEN_HERE" # Generated from $ firebase login:ci
```

2. `$ docker compose build`
3. Go to `http://localhost:7357/` in browser.

or alternatively
### Contributing

1. Run `flutter build web` in terminal.
2. Run `python -m http.server 7357` in terminal.
3. Go to `http://localhost:7357/build/web/` in browser.
1. Make your changes.
2. Submit a pull request.
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.9'
services:
aslearner:
build:
context: .
dockerfile: Dockerfile
args:
PROJECT_ID: ${PROJECT_ID}
FIREBASE_TOKEN: ${FIREBASE_TOKEN}
env_file: .env
ports:
- "7357:80"

0 comments on commit d397357

Please sign in to comment.