Skip to content

Commit eb72617

Browse files
committed
build: add dockerfiles
1 parent c02ad9e commit eb72617

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

app/.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next/**
2+
node_modules/**

app/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:18-alpine
2+
3+
RUN apk update
4+
ARG NODE_ENV=production
5+
ENV NODE_ENV=${NODE_ENV}
6+
7+
ENV DIRECTUS_URL=https://clic.epfl.ch/directus
8+
ENV NEXT_PUBLIC_DIRECTUS_URL=https://clic.epfl.ch/directus
9+
10+
WORKDIR /app
11+
COPY package.json package-lock.json ./
12+
RUN npm config set fetch-retry-maxtimeout 600000 -g && npm ci
13+
14+
COPY . .
15+
RUN npm run build
16+
17+
# switch to unprivileged user from node base image
18+
RUN chown -R node .
19+
USER node
20+
21+
CMD [ "npm", "start" ]

backend/.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/target
2+
.gitignore
3+
4+
.env
5+
.env.example
6+
config.json
7+
8+
README.md

backend/Dockerfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Setup runtime image
2+
FROM debian:bookworm AS runtime
3+
RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates openssl
4+
5+
# Build on a dedicated image to avoid build output in final image
6+
FROM rust:latest AS rust_build
7+
# cargo-build-deps is a tool to only install and build dependencies
8+
RUN cargo install cargo-build-deps
9+
RUN cargo new app
10+
WORKDIR /app
11+
COPY Cargo.toml Cargo.lock ./
12+
RUN cargo build-deps --release
13+
14+
# Add and build project
15+
COPY src ./src
16+
RUN cargo build --release
17+
18+
# Copies build result into runtime image
19+
FROM runtime
20+
21+
WORKDIR /app
22+
23+
ENV DATA_DIR = /data
24+
RUN mkdir /data
25+
26+
ENV ROCKET_ADDRESS=0.0.0.0
27+
28+
COPY --from=rust_build /app/target/release/backend ./backend
29+
30+
ENV RUST_LOG=info
31+
32+
CMD ["./backend"]

0 commit comments

Comments
 (0)