From: Felix Pojtinger Date: Fri, 26 Apr 2019 21:39:21 +0000 (+0200) Subject: build: Start adding implementation X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/static/%7Bthis.props.icon%7D?a=commitdiff_plain;h=bf55be9a2f2939de11f14725153ce55b45504fe1;p=lemmy.git build: Start adding implementation --- diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..7bf77adb --- /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 00000000..4bb4ef5d --- /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 00000000..e00b2fe4 --- /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