From 1d0fb489c39abc18e116d7b9a6fe1f984a62d23f Mon Sep 17 00:00:00 2001 From: Felix Pojtinger Date: Fri, 26 Apr 2019 23:39:21 +0200 Subject: [PATCH] build: Start adding implementation --- Dockerfile.dev | 43 +++++++++++++++++++ skaffold.yaml | 13 ++++++ stack.dev.yaml | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 Dockerfile.dev create mode 100644 skaffold.yaml create mode 100644 stack.dev.yaml diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 000000000..7bf77adb7 --- /dev/null +++ b/Dockerfile.dev @@ -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 diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 000000000..4bb4ef5d6 --- /dev/null +++ b/skaffold.yaml @@ -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 diff --git a/stack.dev.yaml b/stack.dev.yaml new file mode 100644 index 000000000..e00b2fe4c --- /dev/null +++ b/stack.dev.yaml @@ -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