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

move to production #2186

Merged
merged 13 commits into from
Oct 6, 2024
2 changes: 1 addition & 1 deletion k8s/netmanager/values-stage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-platform-frontend
tag: stage-3f13bed4-1727970195
tag: stage-d7da525f-1728122207
pullPolicy: Always
imagePullSecrets: []
nameOverride: ''
Expand Down
138 changes: 69 additions & 69 deletions website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# Stage 1: Build frontend
FROM node:20-slim as frontend-builder

WORKDIR /app

# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci --silent

# Copy source files
COPY webpack.config.js .babelrc ./
COPY frontend ./frontend

# Build frontend
ARG REACT_WEB_STATIC_HOST
ARG REACT_NETMANAGER_BASE_URL
ARG REACT_APP_BASE_AIRQLOUDS_URL
ARG REACT_APP_BASE_NEWSLETTER_URL
ARG REACT_APP_WEBSITE_BASE_URL
ARG REACT_APP_AUTHORIZATION_TOKEN
ARG REACT_APP_GEO_LOCATION_URL
ARG REACT_APP_NETMANAGER_URL
ARG REACT_APP_OPENCAGE_API_KEY

ENV REACT_WEB_STATIC_HOST=$REACT_WEB_STATIC_HOST \
REACT_NETMANAGER_BASE_URL=$REACT_NETMANAGER_BASE_URL \
REACT_APP_BASE_AIRQLOUDS_URL=$REACT_APP_BASE_AIRQLOUDS_URL \
REACT_APP_BASE_NEWSLETTER_URL=$REACT_APP_BASE_NEWSLETTER_URL \
REACT_APP_WEBSITE_BASE_URL=$REACT_APP_WEBSITE_BASE_URL \
REACT_APP_AUTHORIZATION_TOKEN=$REACT_APP_AUTHORIZATION_TOKEN \
REACT_APP_GEO_LOCATION_URL=$REACT_APP_GEO_LOCATION_URL \
REACT_APP_NETMANAGER_URL=$REACT_APP_NETMANAGER_URL \
REACT_APP_OPENCAGE_API_KEY=$REACT_APP_OPENCAGE_API_KEY

RUN npm run build

# Stage 2: Build backend
FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt ./
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

# Copy frontend build
COPY --from=frontend-builder /app/frontend /app/frontend

# Copy backend files
COPY manage.py google_application_credentials.json ./
COPY backend ./backend

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app

# Create a non-root user and switch to it
RUN useradd -m myuser
USER myuser

EXPOSE 8080

# Stage 1: Build frontend
FROM node:20-slim as frontend-builder
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci --silent
# Copy source files
COPY webpack.config.js .babelrc ./
COPY frontend ./frontend
# Build frontend
ARG REACT_WEB_STATIC_HOST
ARG REACT_NETMANAGER_BASE_URL
ARG REACT_APP_BASE_AIRQLOUDS_URL
ARG REACT_APP_BASE_NEWSLETTER_URL
ARG REACT_APP_WEBSITE_BASE_URL
ARG REACT_APP_AUTHORIZATION_TOKEN
ARG REACT_APP_GEO_LOCATION_URL
ARG REACT_APP_NETMANAGER_URL
ARG REACT_APP_OPENCAGE_API_KEY
ENV REACT_WEB_STATIC_HOST=$REACT_WEB_STATIC_HOST \
REACT_NETMANAGER_BASE_URL=$REACT_NETMANAGER_BASE_URL \
REACT_APP_BASE_AIRQLOUDS_URL=$REACT_APP_BASE_AIRQLOUDS_URL \
REACT_APP_BASE_NEWSLETTER_URL=$REACT_APP_BASE_NEWSLETTER_URL \
REACT_APP_WEBSITE_BASE_URL=$REACT_APP_WEBSITE_BASE_URL \
REACT_APP_AUTHORIZATION_TOKEN=$REACT_APP_AUTHORIZATION_TOKEN \
REACT_APP_GEO_LOCATION_URL=$REACT_APP_GEO_LOCATION_URL \
REACT_APP_NETMANAGER_URL=$REACT_APP_NETMANAGER_URL \
REACT_APP_OPENCAGE_API_KEY=$REACT_APP_OPENCAGE_API_KEY
RUN npm run build
# Stage 2: Build backend
FROM python:3.12-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt ./
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy frontend build
COPY --from=frontend-builder /app/frontend /app/frontend
# Copy backend files
COPY manage.py google_application_credentials.json ./
COPY backend ./backend
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
# Create a non-root user and switch to it
RUN useradd -m myuser
USER myuser
EXPOSE 8080
CMD ["sh", "-c", "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn --bind=0.0.0.0:8080 backend.wsgi"]
5 changes: 2 additions & 3 deletions website/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
os.path.join(BASE_DIR, 'frontend', 'templates'),],
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down Expand Up @@ -157,7 +156,7 @@
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "frontend/assets/"),
os.path.join(BASE_DIR, 'frontend'),
os.path.join(BASE_DIR, 'frontend', 'static'),
]
STATIC_URL = STATIC_HOST + "static/"

Expand Down
Loading
Loading