Skip to content

Commit c60d0d4

Browse files
committed
commit v0.0.1a1
0 parents  commit c60d0d4

91 files changed

Lines changed: 10503 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.DS_Store
2+
3+
.git
4+
.gitignore
5+
6+
Dockerfile
7+
.dockerignore
8+
9+
.venv
10+
__pycache__/
11+
12+
# Node
13+
/node_modules
14+
15+
# Database
16+
*.sqlite3
17+
*.db
18+
19+
# IDE
20+
.idea
21+
.vscode
22+
23+
# Other development files
24+
README.md
25+
fixture.json
26+
docker-compose.yml
27+

.github/workflows/release.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Build and Deploy
2+
3+
on:
4+
release:
5+
types: published
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build:
13+
if: '!github.event.release.draft'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ghcr.io/${{ github.repository }}
40+
# enable the 'dev' or 'latest' tag depending on the release type
41+
tags: |
42+
type=pep440,pattern={{version}}
43+
type=raw,value=dev,enable=${{ github.event.release.prerelease }}
44+
flavor: |
45+
latest=${{ !github.event.release.prerelease }}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: .
51+
push: true
52+
platforms: 'linux/amd64,linux/arm64'
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:dev
56+
cache-to: type=inline
57+
58+
outputs:
59+
tag: ${{ steps.meta.outputs.version }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
62+
deploy:
63+
if: '!github.event.release.draft'
64+
runs-on: ubuntu-latest
65+
needs: build
66+
permissions:
67+
contents: read
68+
env:
69+
current: 'ghcr.io/${{ github.repository }}:${{ needs.build.outputs.tag }}'
70+
71+
steps:
72+
- name: Log in to the Container registry
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ghcr.io
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Setup SSH keys
80+
env:
81+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
82+
run: |
83+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
84+
ssh-add - <<< "${{ secrets.SSH_PRIVATE_DEPLOY_KEY }}"
85+
mkdir -p ~/.ssh
86+
echo "${{ secrets.DEPLOY_HOST_KEY }}" >> ~/.ssh/known_hosts
87+
88+
- name: Deploy to production
89+
if: '!github.event.release.prerelease'
90+
env:
91+
DOCKER_HOST: 'ssh://${{ secrets.DEPLOY_DOCKER_USER }}@${{ secrets.DEPLOY_DOCKER_HOST }}'
92+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
93+
run: |
94+
docker service update apecs_app --with-registry-auth --image="${{ env.current }}"
95+
docker service update apecs_worker --with-registry-auth --image="${{ env.current }}"

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules/
2+
3+
apecs/static/dist/
4+
apecs/static/whitenoise/
5+
6+
apecs/db.sqlite3
7+
8+
.idea
9+
**/**/__pycache__/
10+
**/**/.DS_Store
11+
12+
.env

Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# ------------------ STAGE 1: Node / static build ------------------
2+
FROM node:20 AS static
3+
LABEL maintainer="Axel Schlindwein <axel.schlindwein@uit.no>"
4+
5+
WORKDIR /usr/src/apecs
6+
7+
# Copy package files and install dependencies
8+
COPY package*.json ./
9+
RUN npm ci --include=dev
10+
11+
# Copy source and build static assets
12+
COPY . .
13+
RUN npm run build
14+
15+
# Keep only static build artifacts to reduce image size
16+
RUN rm -rf node_modules package*.json apecs/*/static/*
17+
18+
# ------------------ STAGE 2: Python / Django ------------------
19+
FROM python:3.13-slim AS python
20+
LABEL maintainer="Axel Schlindwein <axel.schlindwein@uit.no>"
21+
22+
# System dependencies
23+
RUN apt-get update && apt-get install -y \
24+
gcc python3-dev libjpeg-dev zlib1g-dev curl \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Non-root user
28+
RUN useradd --create-home apecsuser
29+
USER apecsuser
30+
31+
WORKDIR /home/apecsuser/apecs
32+
33+
# Install Poetry
34+
ENV POETRY_HOME=/home/apecsuser/.poetry
35+
ENV PATH="$POETRY_HOME/bin:$PATH"
36+
RUN curl -sSL https://install.python-poetry.org | python3 -
37+
38+
# ------------------ Copy Node build artifacts first ------------------
39+
COPY --from=static --chown=apecsuser /usr/src/apecs/apecs/*/static ./apecs/
40+
41+
# Copy project metadata and install Python dependencies
42+
COPY pyproject.toml poetry.lock ./
43+
RUN poetry config virtualenvs.in-project true \
44+
&& poetry install --no-root
45+
46+
# Add virtualenv to PATH
47+
ENV PATH="/home/apecsuser/apecs/.venv/bin:$PATH"
48+
49+
# Copy remaining source code
50+
COPY --chown=apecsuser . .
51+
52+
# Collect static files
53+
RUN APECS_ALLOWED_HOSTS="" poetry run python manage.py collectstatic --no-input
54+
55+
# Make entrypoint executable
56+
RUN chmod +x ./docker-entrypoint.sh
57+
58+
# Expose Django port
59+
EXPOSE 8000
60+
61+
# Default settings
62+
ENV DJANGO_SETTINGS_MODULE=apecs.settings.prod
63+
64+
# Entrypoint
65+
ENTRYPOINT ["./docker-entrypoint.sh"]

0 commit comments

Comments
 (0)