-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from ASM-Studios/cma/feat-server-docker-setup
feat(docker): add fullstack docker setup
- Loading branch information
Showing
24 changed files
with
331 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
VITE_PORT=8081 | ||
NODE_ENV=development # development or production | ||
VITE_PORT=8081 | ||
|
||
# Server database environment variables | ||
DB_NAME=area | ||
DB_PASSWORD=change-me | ||
DB_HOST=mariadb | ||
DB_PORT=3306 | ||
DB_USER=root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,5 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
ssl/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,11 @@ With AREA, you can create automated workflows that integrate various services an | |
## Table of Contents | ||
|
||
- [Getting Started](#getting-started) | ||
- [Prerequisites](#prerequisites) | ||
- [Installation & Usage](#installation--usage) | ||
- [Prerequisites](#prerequisites) | ||
- [Installation & Usage](#installation--usage) | ||
- [Documentation](#documentation) | ||
- [Requirements](#requirements) | ||
- [Usage](#usage) | ||
- [Requirements](#requirements) | ||
- [Usage](#usage) | ||
- [Tests](#tests) | ||
- [License](#license) | ||
- [Contributors](#contributors) | ||
|
@@ -19,50 +19,39 @@ With AREA, you can create automated workflows that integrate various services an | |
|
||
### Prerequisites | ||
|
||
- vite js | ||
- go | ||
- docker | ||
- make | ||
|
||
### Installation & Usage | ||
|
||
<details> | ||
<summary>Click to expand</summary> | ||
|
||
1. Clone the repo | ||
|
||
```sh | ||
git clone [email protected]:ASM-Studios/AREA.git | ||
``` | ||
|
||
2. Create .env files | ||
|
||
- Run the following command to create private env files | ||
|
||
```sh | ||
cp .env.example .env | ||
cp server/.env.server.example server/.env.server | ||
cp client_web/.env.local.example .env.local | ||
cp client_mobile/.env.mobile.example .env.mobile | ||
``` | ||
|
||
- Fill the .env, .env.web and .env.mobile files | ||
|
||
3. Install NPM packages | ||
```sh | ||
cd AREA/client-web | ||
npm install | ||
``` | ||
4. Run the project | ||
|
||
3. Install Go packages | ||
```sh | ||
cd AREA/server | ||
<TODO> | ||
make start | ||
``` | ||
|
||
4. Run the project | ||
```sh | ||
cd AREA/client-web | ||
npm run start | ||
``` | ||
```sh | ||
cd AREA/server | ||
go run ./... | ||
``` | ||
</details> | ||
|
||
### Documentation | ||
|
@@ -87,6 +76,7 @@ The documentation is automatically built and deployed to GitHub Pages when a pus | |
You can consult the documentation online at [AREA Documentation](https://asm-studios.github.io/AREA/). | ||
|
||
You can build the documentation locally by running the following command: | ||
|
||
```sh | ||
cd AREA/docs | ||
make docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
FROM ghcr.io/cirruslabs/flutter:stable | ||
FROM ghcr.io/cirruslabs/flutter:3.24.5 AS builder | ||
|
||
WORKDIR /app | ||
|
||
ARG VITE_PORT | ||
ARG VITE_ENDPOINT | ||
ARG VITE_GOOGLE_CLIENT_ID | ||
ARG VITE_GOOGLE_CLIENT_SECRET | ||
ARG VITE_MICROSOFT_CLIENT_ID | ||
ARG VITE_LINKEDIN_CLIENT_ID | ||
ARG VITE_LINKEDIN_CLIENT_SECRET | ||
ARG VITE_SPOTIFY_CLIENT_ID | ||
ARG VITE_SPOTIFY_CLIENT_SECRET | ||
# Create a non-root user and give permissions to Android SDK directory | ||
RUN useradd -m -d /home/flutteruser -s /bin/bash flutteruser && \ | ||
chown -R flutteruser:flutteruser /app && \ | ||
chown -R flutteruser:flutteruser /sdks/flutter && \ | ||
chown -R flutteruser:flutteruser /opt/android-sdk-linux && \ | ||
mkdir -p /opt/android-sdk-linux/licenses && \ | ||
chown -R flutteruser:flutteruser /opt/android-sdk-linux/licenses | ||
|
||
USER flutteruser | ||
|
||
RUN git config --global --add safe.directory /sdks/flutter && \ | ||
git config --global --add safe.directory /app | ||
|
||
# Ensure Flutter is properly set up | ||
RUN flutter doctor -v && \ | ||
flutter config --no-analytics | ||
|
||
COPY --chown=flutteruser:flutteruser pubspec.* ./ | ||
|
||
RUN flutter pub get | ||
|
||
COPY --chown=flutteruser:flutteruser . . | ||
|
||
ARG API_URL | ||
ARG WEB_CLIENT_URL | ||
ARG MOBILE_CLIENT_URL | ||
ARG GITHUB_CLIENT_ID | ||
ARG GITHUB_CLIENT_SECRET | ||
|
||
COPY . . | ||
# Accept Android licenses and install SDK components | ||
RUN yes | sdkmanager --licenses && \ | ||
sdkmanager "build-tools;30.0.3" | ||
|
||
RUN flutter pub get | ||
RUN flutter build apk --release | ||
# Clean and get dependencies again after copying all files | ||
RUN flutter clean && \ | ||
flutter pub get | ||
|
||
RUN mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/client.apk | ||
RUN chmod -R 755 build/app/outputs/flutter-apk/ | ||
RUN flutter build apk --release | ||
RUN mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/client.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,67 @@ | ||
###----------------------- Certificate generation stage -----------------------### | ||
FROM alpine:3.19 AS cert-builder | ||
FROM alpine:3.20.3 AS cert-builder | ||
|
||
# Install mkcert dependencies | ||
RUN apk add --no-cache \ | ||
curl \ | ||
nss \ | ||
nss-tools | ||
RUN apk add --no-cache openssl | ||
RUN mkdir -p /etc/nginx/ssl && \ | ||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ | ||
-keyout /etc/nginx/ssl/private.key \ | ||
-out /etc/nginx/ssl/certificate.crt \ | ||
-subj "/C=FR/ST=Paris/L=Paris/O=Area/OU=IT/CN=localhost" \ | ||
-addext "subjectAltName = DNS:localhost" && \ | ||
chmod 644 /etc/nginx/ssl/certificate.crt /etc/nginx/ssl/private.key | ||
|
||
# Install mkcert | ||
RUN curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" \ | ||
&& chmod +x mkcert-v*-linux-amd64 \ | ||
&& mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert \ | ||
&& mkcert -install \ | ||
&& mkcert localhost | ||
###----------------------- Build stage -----------------------### | ||
FROM node:20-alpine AS builder | ||
|
||
WORKDIR /app | ||
|
||
###----------------------- Build stage for Node.js application -----------------------### | ||
FROM node:latest AS builder | ||
COPY package*.json ./ | ||
|
||
WORKDIR /app | ||
RUN if [ "$NODE_ENV" = "production" ] ; then npm ci ; else npm install ; fi | ||
|
||
ARG VITE_PORT | ||
ARG VITE_ENDPOINT | ||
ARG VITE_GOOGLE_CLIENT_ID | ||
ARG VITE_GOOGLE_CLIENT_SECRET | ||
ARG VITE_MICROSOFT_CLIENT_ID | ||
ARG VITE_LINKEDIN_CLIENT_ID | ||
ARG VITE_LINKEDIN_CLIENT_SECRET | ||
ARG VITE_SPOTIFY_CLIENT_ID | ||
ARG VITE_SPOTIFY_CLIENT_SECRET | ||
ARG API_URL | ||
ARG WEB_CLIENT_URL | ||
ARG MOBILE_CLIENT_URL | ||
ARG GITHUB_CLIENT_ID | ||
ARG GITHUB_CLIENT_SECRET | ||
|
||
COPY ./package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
|
||
RUN npm run build | ||
|
||
RUN if [ "$NODE_ENV" = "production" ] ; then npm run build ; fi | ||
|
||
###----------------------- Production stage -----------------------### | ||
FROM nginx:alpine AS production | ||
FROM nginx:1.25.3-alpine AS production | ||
|
||
ARG VITE_PORT | ||
|
||
RUN adduser -D nginxuser && \ | ||
mkdir -p /usr/share/nginx/html/mobile_builds && \ | ||
mkdir -p /etc/nginx/ssl && \ | ||
chown -R nginxuser:nginxuser /usr/share/nginx/html && \ | ||
chown -R nginxuser:nginxuser /etc/nginx/ssl && \ | ||
chown -R nginxuser:nginxuser /var/cache/nginx && \ | ||
chown -R nginxuser:nginxuser /var/log/nginx && \ | ||
touch /var/run/nginx.pid && \ | ||
chown -R nginxuser:nginxuser /var/run/nginx.pid | ||
|
||
COPY --from=builder /app/dist /usr/share/nginx/html | ||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf | ||
RUN mkdir -p /usr/share/nginx/html/mobile_builds | ||
COPY --from=cert-builder --chown=nginxuser:nginxuser /etc/nginx/ssl /etc/nginx/ssl | ||
COPY --from=builder --chown=nginxuser:nginxuser /app/dist /usr/share/nginx/html | ||
COPY --chown=nginxuser:nginxuser ./nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
USER nginxuser | ||
|
||
EXPOSE ${VITE_PORT} | ||
|
||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | ||
CMD wget --no-verbose --tries=1 --spider http://localhost:${VITE_PORT}/health || exit 1 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] | ||
|
||
###----------------------- Development stage -----------------------### | ||
FROM builder AS development | ||
|
||
RUN apk add --no-cache \ | ||
nss-tools \ | ||
curl \ | ||
&& curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" \ | ||
&& chmod +x mkcert-v*-linux-amd64 \ | ||
&& cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert | ||
|
||
ENV NODE_ENV=development | ||
EXPOSE ${VITE_PORT} | ||
|
||
CMD ["nginx", "-g", "daemon off;"] | ||
CMD ["sh", "-c", "if [ ! -f localhost-key.pem ]; then mkcert -install && mkcert localhost; fi && mv localhost*.pem /app/ && npm run dev -- --host"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
services: | ||
area-client-web: | ||
build: | ||
target: development | ||
volumes: | ||
- ./client_web:/app | ||
- /app/node_modules | ||
- ssl-certs:/app/certs | ||
environment: | ||
- NODE_ENV=development | ||
- CHOKIDAR_USEPOLLING=true | ||
|
||
area-server: | ||
build: | ||
target: development | ||
volumes: | ||
- ./server:/app | ||
- go-modules:/go/pkg/mod | ||
environment: | ||
- GO_ENV=development | ||
|
||
volumes: | ||
ssl-certs: | ||
go-modules: |
Oops, something went wrong.