Last active
November 28, 2022 19:16
-
-
Save yaredc/9839783d1232aa11d30cafe06308dfc4 to your computer and use it in GitHub Desktop.
rust.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
services: | |
rust: | |
ports: | |
- "8000:8000" | |
postgres: | |
ports: | |
- "5432:5432" | |
redis: | |
ports: | |
- "6379:6379" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
volumes: | |
postgres: | |
services: | |
rust: | |
build: | |
context: . | |
dockerfile: rust.dockerfile | |
restart: always | |
volumes: | |
- ./:/srv/work/source | |
working_dir: /srv/work/source | |
node: | |
image: library/node:latest | |
restart: always | |
volumes: | |
- ./:/srv/work/source | |
working_dir: /srv/work/source | |
redis: | |
image: library/redis:latest | |
restart: always | |
postgres: | |
image: library/postgres:14.5 | |
restart: always | |
volumes: | |
- postgres:/var/lib/postgresql/data | |
environment: | |
POSTGRES_PASSWORD: app | |
POSTGRES_USER: app | |
POSTGRES_DB: app | |
mailhog: | |
image: mailhog/mailhog:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOCKER_BASE?=docker-compose -f docker-compose.yml -f docker-compose.local.yml | |
DOCKER_RUST_RUN?=$(DOCKER_BASE) run --rm rust | |
### DOCKER | |
dbuild: | |
$(DOCKER_BASE) build | |
dclean: | |
$(DOCKER_RUST_RUN) cargo clean | |
drun: dclean | |
$(DOCKER_RUST_RUN) cargo run | |
dbash: dclean | |
$(DOCKER_RUST_RUN) bash | |
### LOCAL | |
clean: | |
cargo clean | |
run: clean | |
cargo run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM library/rust:latest | |
ENV TZ="Europe/Berlin" \ | |
USER="worker" \ | |
GROUP="worker" \ | |
WORKDIR="/srv/work/source" \ | |
HOMEDIR="/srv/.worker" | |
# https://docs.docker.com/engine/install/linux-postinstall/ | |
# sudo groupadd docker | |
# sudo usermod -aG docker $USER | |
RUN useradd -u 1000 -U -M $USER && \ | |
mkdir -p $WORKDIR &&\ | |
mkdir -p $HOMEDIR &&\ | |
usermod -d $HOMEDIR $USER | |
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime &&\ | |
echo "$TZ" > /etc/timezone | |
RUN rustup component add rustfmt | |
RUN chown -R $USER:$USER $WORKDIR &&\ | |
chown -R $USER:$USER $RUSTUP_HOME &&\ | |
chown -R $USER:$USER $CARGO_HOME | |
WORKDIR $WORKDIR | |
USER $USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment