Skip to content

Commit

Permalink
Docker Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
russfeld committed Mar 3, 2024
1 parent 487762a commit 6ec2585
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
2 changes: 0 additions & 2 deletions js-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ RUN --mount=type=bind,source=client/package.json,target=package.json \
# Copy the rest of the source files into the image.
COPY ./client .

RUN cat /usr/src/app/vite.config.js

RUN npm run build

FROM node:${NODE_VERSION}-alpine as server
Expand Down
2 changes: 1 addition & 1 deletion js-docker/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build --emptyOutDir --outDir ../server/public",
"build": "vite build --emptyOutDir",
"preview": "vite preview"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion js-docker/server/db/password.txt

This file was deleted.

2 changes: 1 addition & 1 deletion js-docker/server/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var express = require('express');
var router = express.Router();

const pgp = require('pg-promise')(/* options */)
const db = pgp('postgres://postgres:postgres@db:5432/postgres')
const db = pgp('postgres://postgres:postgres@postgres:5432/postgres')


/* GET users listing. */
Expand Down
11 changes: 5 additions & 6 deletions py-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

ARG NODE_VERSION=20

ARG PYTHON_VERSION=3.10.12

FROM node:${NODE_VERSION}-alpine as client

# Use production node environment by default.
Expand All @@ -30,11 +32,8 @@ RUN --mount=type=bind,source=client/package.json,target=package.json \
# Copy the rest of the source files into the image.
COPY ./client .

RUN cat /usr/src/app/vite.config.js

RUN npm run build

ARG PYTHON_VERSION=3.10.12
FROM python:${PYTHON_VERSION}-slim as base

# Prevents Python from writing pyc files.
Expand All @@ -44,7 +43,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

WORKDIR /app
WORKDIR /usr/src/app

# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
Expand All @@ -63,14 +62,14 @@ RUN adduser \
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
--mount=type=bind,source=server/requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt

# Switch to the non-privileged user to run the application.
USER appuser

# Copy the source code into the container.
COPY . .
COPY ./server .

COPY --from=client /usr/src/app/dist ./public

Expand Down
2 changes: 1 addition & 1 deletion py-docker/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build --emptyOutDir --outDir ../server/public",
"build": "vite build --emptyOutDir",
"preview": "vite preview"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions py-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# https://github.com/compose-spec/compose-spec/blob/master/spec.md
services:

server:
build:
context: .
container_name: py-server
ports:
- 5001:5001

postgres:
# ***************************************************************************
# Postgres Database
Expand Down
1 change: 0 additions & 1 deletion py-docker/server/db/password.txt

This file was deleted.

0 comments on commit 6ec2585

Please sign in to comment.