build: Start adding implementation

This commit is contained in:
Felix Pojtinger 2019-04-26 23:39:21 +02:00
parent bc91163467
commit 1d0fb489c3
3 changed files with 169 additions and 0 deletions

43
Dockerfile.dev Normal file
View File

@ -0,0 +1,43 @@
FROM node:10-jessie
#If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy'
WORKDIR /app/ui
COPY ui/package.json ui/yarn.lock ./
RUN yarn install --pure-lockfile # This caches your deps
COPY ui /app/ui
RUN yarn build
FROM rust:1.33
# create a new empty shell project
WORKDIR /app
RUN USER=root cargo new server
WORKDIR /app/server
# copy over your manifests
COPY server/Cargo.toml server/Cargo.lock ./
# this build step will cache your dependencies
RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
RUN cargo build --release --bin lemmy
RUN rm -r ./target/release/.fingerprint/server-*
# copy your source tree
# RUN rm -rf ./src/
COPY server/src ./src/
COPY server/migrations ./migrations/
# build for release
RUN cargo build --frozen --release --bin lemmy
RUN mv /app/server/target/release/lemmy /app/lemmy
# Get diesel-cli on there just in case
# RUN cargo install diesel_cli --no-default-features --features postgres
# The output image
# FROM debian:stable-slim
# RUN apt-get -y update && apt-get install -y postgresql-client
# COPY --from=rust /app/server/target/release/lemmy /app/lemmy
# COPY --from=0 /app/ui/dist /app/dist
EXPOSE 8536

13
skaffold.yaml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: skaffold/v1beta9
kind: Config
profiles:
- name: lemmy--dev--no-sync
build:
artifacts:
- image: registry.gitlab.com/pojntfx/lemmy/lemmy
docker:
dockerfile: Dockerfile.dev
deploy:
kubectl:
manifests:
- stack.dev.yaml

113
stack.dev.yaml Normal file
View File

@ -0,0 +1,113 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres
data:
POSTGRES_PASSWORD: rrr
POSTGRES_USER: rrr
POSTGRES_DB: rrr
PGDATA: /var/lib/postgresql/data/pgdata
DATABASE_URL: postgres://rrr:rrr@postgres:5432/rrr
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:11.2-alpine
resources:
limits:
memory: 128Mi
cpu: 500m
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres
volumeMounts:
- name: postgres
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres
persistentVolumeClaim:
claimName: postgres
---
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- port: 5432
---
apiVersion: v1
kind: ConfigMap
metadata:
name: lemmy
data:
LEMMY_FRONT_END_DIR: /app/dist
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: lemmy
spec:
selector:
matchLabels:
app: lemmy
template:
metadata:
labels:
app: lemmy
spec:
containers:
- name: lemmy
command:
- /bin/sh -c /app/lemmy
envFrom:
- configMapRef:
name: lemmy
- configMapRef:
name: postgres
image: registry.gitlab.com/pojntfx/lemmy/lemmy
resources:
limits:
memory: 128Mi
cpu: 500m
ports:
- containerPort: 8536
---
apiVersion: v1
kind: Service
metadata:
name: lemmy
spec:
type: NodePort
selector:
app: lemmy
ports:
- port: 8536
nodePort: 30001