Skip to content

Commit 26e5df1

Browse files
committed
Added the dockerfiles needed to create docker images out of the students' repositories and .dockerignore files
1 parent e640f0e commit 26e5df1

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

Docker-files/flask/.dockerignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.idea/
2+
.vscode/
3+
4+
*venv/
5+
__pycache__/
6+
7+
Dockerfile
8+
9+
.gitignore
10+
README.md
11+
.git/
12+
.github

Docker-files/flask/Dockerfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.12.3-slim AS base
2+
# ------------------------ Initial image build ---------------------------
3+
FROM base AS build
4+
5+
WORKDIR /usr/app
6+
7+
RUN python -m venv /usr/app/venv
8+
ENV PATH="/usr/app/venv/bin:$PATH"
9+
10+
COPY requirements.txt .
11+
RUN echo "gunicorn==20.0.4" >> requirements.txt
12+
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
build-essential gcc && pip install -r requirements.txt
15+
16+
# ------------------------ Production Build -------------------------------
17+
FROM base
18+
19+
RUN groupadd -g 999 python && \
20+
useradd -r -u 999 -g python python
21+
22+
RUN mkdir /usr/app && chown python:python /usr/app
23+
24+
WORKDIR /usr/app
25+
26+
COPY --chown=python:python --from=build /usr/app/venv ./venv
27+
COPY --chown=python:python . .
28+
29+
USER 999
30+
31+
ENV PATH="/usr/app/venv/bin:$PATH"
32+
CMD [ "gunicorn", "--bind", "0.0.0.0:3000", "manage:app" ]

Docker-files/node-js/.dockerignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
dist-types
2+
node_modules
3+
dist
4+
build
5+
6+
7+
packages/*/dist
8+
packages/*/node_modules
9+
plugins/*/dist
10+
plugins/*/node_modules
11+
12+
Dockerfile
13+
.dockerignore
14+
15+
.git
16+
.github
17+
.gitignore

Docker-files/node-js/Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:20.12.2-bullseye-slim AS base
2+
# ---------------------- Initial image build ---------------------
3+
FROM base AS build
4+
5+
WORKDIR /usr/src/app
6+
7+
COPY package*.json /usr/src/app/
8+
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends dumb-init \
11+
&& npm ci --only=production
12+
13+
# ------------------------ Production Image ---------------------
14+
FROM base
15+
16+
WORKDIR /usr/src/app
17+
18+
ENV NODE_ENV production
19+
20+
COPY --from=build /usr/bin/dumb-init /usr/bin/dumb-init
21+
22+
USER node
23+
24+
COPY --chown=node:node --from=build /usr/src/app/node_modules /usr/src/app/node_modules
25+
COPY --chown=node:node . /usr/src/app
26+
27+
CMD ["dumb-init", "node", "server.js"]

0 commit comments

Comments
 (0)