Skip to content

Commit

Permalink
Merge pull request #57 from kochamaltki/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
Dromader2137 authored Apr 8, 2024
2 parents f1836e0 + 88849af commit f4a3293
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
media/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:trusty
RUN sudo apt-get -y update
RUN sudo apt-get -y upgrade
RUN sudo apt-get install -y sqlite3 libsqlite3-dev curl
WORKDIR /usr/src/backend
SHELL ["/bin/bash", "-c"]
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN ls -a /root
RUN source "/root/.cargo/env"
RUN /root/.cargo/bin/rustc -V
RUN mkdir -p ./media/images
RUN mkdir -p ./media/profile-pictures
COPY . .
RUN /usr/bin/sqlite3 projekt-db < setup.sql
RUN ls -a
RUN /root/.cargo/bin/cargo build
CMD /root/.cargo/bin/cargo run
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
- Install sqlite (sqlite3, libsqlite3-dev packages)
- Install gcc
- Install rust
- Install docker, docker compose (optional)
- If you want to use the test scripts, install curl
- Create media/image, media/profile_pictures
### Running
- Before the first deploy, create a file `SECRET` in the root directory, with its content being a base64 secret
- Run `./deploy.sh` from the root directory
- Docker: First `docker build -t backend .` and run `docker compose up` from the root directory
### Acces points
#### /api/get/posts/by-user/{id}
- Get: 200 (PostList) / 404 ("User not found")
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'

services:
backend:
image: backend:latest
container_name: backend
ports:
- "8000:8000"
environment:
- PUID=1000
- PGID=1000
volumes:
- ./media:/usr/src/backend/media
2 changes: 1 addition & 1 deletion setup-db.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

sqlite3 projekt-db < setup.sql
/usr/bin/sqlite3 projekt-db < setup.sql

0 comments on commit f4a3293

Please sign in to comment.